6lowpan.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. /*
  2. Copyright (c) 2013-2014 Intel Corp.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License version 2 and
  5. only version 2 as published by the Free Software Foundation.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. */
  11. #include <linux/if_arp.h>
  12. #include <linux/netdevice.h>
  13. #include <linux/etherdevice.h>
  14. #include <linux/module.h>
  15. #include <linux/debugfs.h>
  16. #include <net/ipv6.h>
  17. #include <net/ip6_route.h>
  18. #include <net/addrconf.h>
  19. #include <net/bluetooth/bluetooth.h>
  20. #include <net/bluetooth/hci_core.h>
  21. #include <net/bluetooth/l2cap.h>
  22. #include <net/6lowpan.h> /* for the compression support */
  23. #define VERSION "0.1"
  24. static struct dentry *lowpan_enable_debugfs;
  25. static struct dentry *lowpan_control_debugfs;
  26. #define IFACE_NAME_TEMPLATE "bt%d"
  27. struct skb_cb {
  28. struct in6_addr addr;
  29. struct in6_addr gw;
  30. struct l2cap_chan *chan;
  31. int status;
  32. };
  33. #define lowpan_cb(skb) ((struct skb_cb *)((skb)->cb))
  34. /* The devices list contains those devices that we are acting
  35. * as a proxy. The BT 6LoWPAN device is a virtual device that
  36. * connects to the Bluetooth LE device. The real connection to
  37. * BT device is done via l2cap layer. There exists one
  38. * virtual device / one BT 6LoWPAN network (=hciX device).
  39. * The list contains struct lowpan_dev elements.
  40. */
  41. static LIST_HEAD(bt_6lowpan_devices);
  42. static DEFINE_SPINLOCK(devices_lock);
  43. static bool enable_6lowpan;
  44. /* We are listening incoming connections via this channel
  45. */
  46. static struct l2cap_chan *listen_chan;
  47. struct lowpan_peer {
  48. struct list_head list;
  49. struct rcu_head rcu;
  50. struct l2cap_chan *chan;
  51. /* peer addresses in various formats */
  52. unsigned char eui64_addr[EUI64_ADDR_LEN];
  53. struct in6_addr peer_addr;
  54. };
  55. struct lowpan_btle_dev {
  56. struct list_head list;
  57. struct hci_dev *hdev;
  58. struct net_device *netdev;
  59. struct list_head peers;
  60. atomic_t peer_count; /* number of items in peers list */
  61. struct work_struct delete_netdev;
  62. struct delayed_work notify_peers;
  63. };
  64. static inline struct lowpan_btle_dev *
  65. lowpan_btle_dev(const struct net_device *netdev)
  66. {
  67. return (struct lowpan_btle_dev *)lowpan_dev(netdev)->priv;
  68. }
  69. static inline void peer_add(struct lowpan_btle_dev *dev,
  70. struct lowpan_peer *peer)
  71. {
  72. list_add_rcu(&peer->list, &dev->peers);
  73. atomic_inc(&dev->peer_count);
  74. }
  75. static inline bool peer_del(struct lowpan_btle_dev *dev,
  76. struct lowpan_peer *peer)
  77. {
  78. list_del_rcu(&peer->list);
  79. kfree_rcu(peer, rcu);
  80. module_put(THIS_MODULE);
  81. if (atomic_dec_and_test(&dev->peer_count)) {
  82. BT_DBG("last peer");
  83. return true;
  84. }
  85. return false;
  86. }
  87. static inline struct lowpan_peer *peer_lookup_ba(struct lowpan_btle_dev *dev,
  88. bdaddr_t *ba, __u8 type)
  89. {
  90. struct lowpan_peer *peer;
  91. BT_DBG("peers %d addr %pMR type %d", atomic_read(&dev->peer_count),
  92. ba, type);
  93. rcu_read_lock();
  94. list_for_each_entry_rcu(peer, &dev->peers, list) {
  95. BT_DBG("dst addr %pMR dst type %d",
  96. &peer->chan->dst, peer->chan->dst_type);
  97. if (bacmp(&peer->chan->dst, ba))
  98. continue;
  99. if (type == peer->chan->dst_type) {
  100. rcu_read_unlock();
  101. return peer;
  102. }
  103. }
  104. rcu_read_unlock();
  105. return NULL;
  106. }
  107. static inline struct lowpan_peer *
  108. __peer_lookup_chan(struct lowpan_btle_dev *dev, struct l2cap_chan *chan)
  109. {
  110. struct lowpan_peer *peer;
  111. list_for_each_entry_rcu(peer, &dev->peers, list) {
  112. if (peer->chan == chan)
  113. return peer;
  114. }
  115. return NULL;
  116. }
  117. static inline struct lowpan_peer *
  118. __peer_lookup_conn(struct lowpan_btle_dev *dev, struct l2cap_conn *conn)
  119. {
  120. struct lowpan_peer *peer;
  121. list_for_each_entry_rcu(peer, &dev->peers, list) {
  122. if (peer->chan->conn == conn)
  123. return peer;
  124. }
  125. return NULL;
  126. }
  127. static inline struct lowpan_peer *peer_lookup_dst(struct lowpan_btle_dev *dev,
  128. struct in6_addr *daddr,
  129. struct sk_buff *skb)
  130. {
  131. struct lowpan_peer *peer;
  132. struct in6_addr *nexthop;
  133. struct rt6_info *rt = (struct rt6_info *)skb_dst(skb);
  134. int count = atomic_read(&dev->peer_count);
  135. BT_DBG("peers %d addr %pI6c rt %p", count, daddr, rt);
  136. /* If we have multiple 6lowpan peers, then check where we should
  137. * send the packet. If only one peer exists, then we can send the
  138. * packet right away.
  139. */
  140. if (count == 1) {
  141. rcu_read_lock();
  142. peer = list_first_or_null_rcu(&dev->peers, struct lowpan_peer,
  143. list);
  144. rcu_read_unlock();
  145. return peer;
  146. }
  147. if (!rt) {
  148. if (ipv6_addr_any(&lowpan_cb(skb)->gw)) {
  149. /* There is neither route nor gateway,
  150. * probably the destination is a direct peer.
  151. */
  152. nexthop = daddr;
  153. } else {
  154. /* There is a known gateway
  155. */
  156. nexthop = &lowpan_cb(skb)->gw;
  157. }
  158. } else {
  159. nexthop = rt6_nexthop(rt, daddr);
  160. /* We need to remember the address because it is needed
  161. * by bt_xmit() when sending the packet. In bt_xmit(), the
  162. * destination routing info is not set.
  163. */
  164. memcpy(&lowpan_cb(skb)->gw, nexthop, sizeof(struct in6_addr));
  165. }
  166. BT_DBG("gw %pI6c", nexthop);
  167. rcu_read_lock();
  168. list_for_each_entry_rcu(peer, &dev->peers, list) {
  169. BT_DBG("dst addr %pMR dst type %d ip %pI6c",
  170. &peer->chan->dst, peer->chan->dst_type,
  171. &peer->peer_addr);
  172. if (!ipv6_addr_cmp(&peer->peer_addr, nexthop)) {
  173. rcu_read_unlock();
  174. return peer;
  175. }
  176. }
  177. rcu_read_unlock();
  178. return NULL;
  179. }
  180. static struct lowpan_peer *lookup_peer(struct l2cap_conn *conn)
  181. {
  182. struct lowpan_btle_dev *entry;
  183. struct lowpan_peer *peer = NULL;
  184. rcu_read_lock();
  185. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  186. peer = __peer_lookup_conn(entry, conn);
  187. if (peer)
  188. break;
  189. }
  190. rcu_read_unlock();
  191. return peer;
  192. }
  193. static struct lowpan_btle_dev *lookup_dev(struct l2cap_conn *conn)
  194. {
  195. struct lowpan_btle_dev *entry;
  196. struct lowpan_btle_dev *dev = NULL;
  197. rcu_read_lock();
  198. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  199. if (conn->hcon->hdev == entry->hdev) {
  200. dev = entry;
  201. break;
  202. }
  203. }
  204. rcu_read_unlock();
  205. return dev;
  206. }
  207. static int give_skb_to_upper(struct sk_buff *skb, struct net_device *dev)
  208. {
  209. struct sk_buff *skb_cp;
  210. skb_cp = skb_copy(skb, GFP_ATOMIC);
  211. if (!skb_cp)
  212. return NET_RX_DROP;
  213. return netif_rx_ni(skb_cp);
  214. }
  215. static int iphc_decompress(struct sk_buff *skb, struct net_device *netdev,
  216. struct l2cap_chan *chan)
  217. {
  218. const u8 *saddr, *daddr;
  219. struct lowpan_btle_dev *dev;
  220. struct lowpan_peer *peer;
  221. dev = lowpan_btle_dev(netdev);
  222. rcu_read_lock();
  223. peer = __peer_lookup_chan(dev, chan);
  224. rcu_read_unlock();
  225. if (!peer)
  226. return -EINVAL;
  227. saddr = peer->eui64_addr;
  228. daddr = dev->netdev->dev_addr;
  229. return lowpan_header_decompress(skb, netdev, daddr, saddr);
  230. }
  231. static int recv_pkt(struct sk_buff *skb, struct net_device *dev,
  232. struct l2cap_chan *chan)
  233. {
  234. struct sk_buff *local_skb;
  235. int ret;
  236. if (!netif_running(dev))
  237. goto drop;
  238. if (dev->type != ARPHRD_6LOWPAN || !skb->len)
  239. goto drop;
  240. skb_reset_network_header(skb);
  241. skb = skb_share_check(skb, GFP_ATOMIC);
  242. if (!skb)
  243. goto drop;
  244. /* check that it's our buffer */
  245. if (lowpan_is_ipv6(*skb_network_header(skb))) {
  246. /* Pull off the 1-byte of 6lowpan header. */
  247. skb_pull(skb, 1);
  248. /* Copy the packet so that the IPv6 header is
  249. * properly aligned.
  250. */
  251. local_skb = skb_copy_expand(skb, NET_SKB_PAD - 1,
  252. skb_tailroom(skb), GFP_ATOMIC);
  253. if (!local_skb)
  254. goto drop;
  255. local_skb->protocol = htons(ETH_P_IPV6);
  256. local_skb->pkt_type = PACKET_HOST;
  257. local_skb->dev = dev;
  258. skb_set_transport_header(local_skb, sizeof(struct ipv6hdr));
  259. if (give_skb_to_upper(local_skb, dev) != NET_RX_SUCCESS) {
  260. kfree_skb(local_skb);
  261. goto drop;
  262. }
  263. dev->stats.rx_bytes += skb->len;
  264. dev->stats.rx_packets++;
  265. consume_skb(local_skb);
  266. consume_skb(skb);
  267. } else if (lowpan_is_iphc(*skb_network_header(skb))) {
  268. local_skb = skb_clone(skb, GFP_ATOMIC);
  269. if (!local_skb)
  270. goto drop;
  271. local_skb->dev = dev;
  272. ret = iphc_decompress(local_skb, dev, chan);
  273. if (ret < 0) {
  274. kfree_skb(local_skb);
  275. goto drop;
  276. }
  277. local_skb->protocol = htons(ETH_P_IPV6);
  278. local_skb->pkt_type = PACKET_HOST;
  279. if (give_skb_to_upper(local_skb, dev)
  280. != NET_RX_SUCCESS) {
  281. kfree_skb(local_skb);
  282. goto drop;
  283. }
  284. dev->stats.rx_bytes += skb->len;
  285. dev->stats.rx_packets++;
  286. consume_skb(local_skb);
  287. consume_skb(skb);
  288. } else {
  289. goto drop;
  290. }
  291. return NET_RX_SUCCESS;
  292. drop:
  293. dev->stats.rx_dropped++;
  294. return NET_RX_DROP;
  295. }
  296. /* Packet from BT LE device */
  297. static int chan_recv_cb(struct l2cap_chan *chan, struct sk_buff *skb)
  298. {
  299. struct lowpan_btle_dev *dev;
  300. struct lowpan_peer *peer;
  301. int err;
  302. peer = lookup_peer(chan->conn);
  303. if (!peer)
  304. return -ENOENT;
  305. dev = lookup_dev(chan->conn);
  306. if (!dev || !dev->netdev)
  307. return -ENOENT;
  308. err = recv_pkt(skb, dev->netdev, chan);
  309. if (err) {
  310. BT_DBG("recv pkt %d", err);
  311. err = -EAGAIN;
  312. }
  313. return err;
  314. }
  315. static u8 get_addr_type_from_eui64(u8 byte)
  316. {
  317. /* Is universal(0) or local(1) bit */
  318. return ((byte & 0x02) ? BDADDR_LE_RANDOM : BDADDR_LE_PUBLIC);
  319. }
  320. static void copy_to_bdaddr(struct in6_addr *ip6_daddr, bdaddr_t *addr)
  321. {
  322. u8 *eui64 = ip6_daddr->s6_addr + 8;
  323. addr->b[0] = eui64[7];
  324. addr->b[1] = eui64[6];
  325. addr->b[2] = eui64[5];
  326. addr->b[3] = eui64[2];
  327. addr->b[4] = eui64[1];
  328. addr->b[5] = eui64[0];
  329. }
  330. static void convert_dest_bdaddr(struct in6_addr *ip6_daddr,
  331. bdaddr_t *addr, u8 *addr_type)
  332. {
  333. copy_to_bdaddr(ip6_daddr, addr);
  334. /* We need to toggle the U/L bit that we got from IPv6 address
  335. * so that we get the proper address and type of the BD address.
  336. */
  337. addr->b[5] ^= 0x02;
  338. *addr_type = get_addr_type_from_eui64(addr->b[5]);
  339. }
  340. static int setup_header(struct sk_buff *skb, struct net_device *netdev,
  341. bdaddr_t *peer_addr, u8 *peer_addr_type)
  342. {
  343. struct in6_addr ipv6_daddr;
  344. struct ipv6hdr *hdr;
  345. struct lowpan_btle_dev *dev;
  346. struct lowpan_peer *peer;
  347. bdaddr_t addr, *any = BDADDR_ANY;
  348. u8 *daddr = any->b;
  349. int err, status = 0;
  350. hdr = ipv6_hdr(skb);
  351. dev = lowpan_btle_dev(netdev);
  352. memcpy(&ipv6_daddr, &hdr->daddr, sizeof(ipv6_daddr));
  353. if (ipv6_addr_is_multicast(&ipv6_daddr)) {
  354. lowpan_cb(skb)->chan = NULL;
  355. } else {
  356. u8 addr_type;
  357. /* Get destination BT device from skb.
  358. * If there is no such peer then discard the packet.
  359. */
  360. convert_dest_bdaddr(&ipv6_daddr, &addr, &addr_type);
  361. BT_DBG("dest addr %pMR type %d IP %pI6c", &addr,
  362. addr_type, &ipv6_daddr);
  363. peer = peer_lookup_ba(dev, &addr, addr_type);
  364. if (!peer) {
  365. /* The packet might be sent to 6lowpan interface
  366. * because of routing (either via default route
  367. * or user set route) so get peer according to
  368. * the destination address.
  369. */
  370. peer = peer_lookup_dst(dev, &ipv6_daddr, skb);
  371. if (!peer) {
  372. BT_DBG("no such peer %pMR found", &addr);
  373. return -ENOENT;
  374. }
  375. }
  376. daddr = peer->eui64_addr;
  377. *peer_addr = addr;
  378. *peer_addr_type = addr_type;
  379. lowpan_cb(skb)->chan = peer->chan;
  380. status = 1;
  381. }
  382. lowpan_header_compress(skb, netdev, daddr, dev->netdev->dev_addr);
  383. err = dev_hard_header(skb, netdev, ETH_P_IPV6, NULL, NULL, 0);
  384. if (err < 0)
  385. return err;
  386. return status;
  387. }
  388. static int header_create(struct sk_buff *skb, struct net_device *netdev,
  389. unsigned short type, const void *_daddr,
  390. const void *_saddr, unsigned int len)
  391. {
  392. if (type != ETH_P_IPV6)
  393. return -EINVAL;
  394. return 0;
  395. }
  396. /* Packet to BT LE device */
  397. static int send_pkt(struct l2cap_chan *chan, struct sk_buff *skb,
  398. struct net_device *netdev)
  399. {
  400. struct msghdr msg;
  401. struct kvec iv;
  402. int err;
  403. /* Remember the skb so that we can send EAGAIN to the caller if
  404. * we run out of credits.
  405. */
  406. chan->data = skb;
  407. iv.iov_base = skb->data;
  408. iv.iov_len = skb->len;
  409. memset(&msg, 0, sizeof(msg));
  410. iov_iter_kvec(&msg.msg_iter, WRITE | ITER_KVEC, &iv, 1, skb->len);
  411. err = l2cap_chan_send(chan, &msg, skb->len);
  412. if (err > 0) {
  413. netdev->stats.tx_bytes += err;
  414. netdev->stats.tx_packets++;
  415. return 0;
  416. }
  417. if (!err)
  418. err = lowpan_cb(skb)->status;
  419. if (err < 0) {
  420. if (err == -EAGAIN)
  421. netdev->stats.tx_dropped++;
  422. else
  423. netdev->stats.tx_errors++;
  424. }
  425. return err;
  426. }
  427. static int send_mcast_pkt(struct sk_buff *skb, struct net_device *netdev)
  428. {
  429. struct sk_buff *local_skb;
  430. struct lowpan_btle_dev *entry;
  431. int err = 0;
  432. rcu_read_lock();
  433. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  434. struct lowpan_peer *pentry;
  435. struct lowpan_btle_dev *dev;
  436. if (entry->netdev != netdev)
  437. continue;
  438. dev = lowpan_btle_dev(entry->netdev);
  439. list_for_each_entry_rcu(pentry, &dev->peers, list) {
  440. int ret;
  441. local_skb = skb_clone(skb, GFP_ATOMIC);
  442. BT_DBG("xmit %s to %pMR type %d IP %pI6c chan %p",
  443. netdev->name,
  444. &pentry->chan->dst, pentry->chan->dst_type,
  445. &pentry->peer_addr, pentry->chan);
  446. ret = send_pkt(pentry->chan, local_skb, netdev);
  447. if (ret < 0)
  448. err = ret;
  449. kfree_skb(local_skb);
  450. }
  451. }
  452. rcu_read_unlock();
  453. return err;
  454. }
  455. static netdev_tx_t bt_xmit(struct sk_buff *skb, struct net_device *netdev)
  456. {
  457. int err = 0;
  458. bdaddr_t addr;
  459. u8 addr_type;
  460. /* We must take a copy of the skb before we modify/replace the ipv6
  461. * header as the header could be used elsewhere
  462. */
  463. skb = skb_unshare(skb, GFP_ATOMIC);
  464. if (!skb)
  465. return NET_XMIT_DROP;
  466. /* Return values from setup_header()
  467. * <0 - error, packet is dropped
  468. * 0 - this is a multicast packet
  469. * 1 - this is unicast packet
  470. */
  471. err = setup_header(skb, netdev, &addr, &addr_type);
  472. if (err < 0) {
  473. kfree_skb(skb);
  474. return NET_XMIT_DROP;
  475. }
  476. if (err) {
  477. if (lowpan_cb(skb)->chan) {
  478. BT_DBG("xmit %s to %pMR type %d IP %pI6c chan %p",
  479. netdev->name, &addr, addr_type,
  480. &lowpan_cb(skb)->addr, lowpan_cb(skb)->chan);
  481. err = send_pkt(lowpan_cb(skb)->chan, skb, netdev);
  482. } else {
  483. err = -ENOENT;
  484. }
  485. } else {
  486. /* We need to send the packet to every device behind this
  487. * interface.
  488. */
  489. err = send_mcast_pkt(skb, netdev);
  490. }
  491. dev_kfree_skb(skb);
  492. if (err)
  493. BT_DBG("ERROR: xmit failed (%d)", err);
  494. return err < 0 ? NET_XMIT_DROP : err;
  495. }
  496. static int bt_dev_init(struct net_device *dev)
  497. {
  498. netdev_lockdep_set_classes(dev);
  499. return 0;
  500. }
  501. static const struct net_device_ops netdev_ops = {
  502. .ndo_init = bt_dev_init,
  503. .ndo_start_xmit = bt_xmit,
  504. };
  505. static struct header_ops header_ops = {
  506. .create = header_create,
  507. };
  508. static void netdev_setup(struct net_device *dev)
  509. {
  510. dev->hard_header_len = 0;
  511. dev->needed_tailroom = 0;
  512. dev->flags = IFF_RUNNING | IFF_POINTOPOINT |
  513. IFF_MULTICAST;
  514. dev->watchdog_timeo = 0;
  515. dev->netdev_ops = &netdev_ops;
  516. dev->header_ops = &header_ops;
  517. dev->destructor = free_netdev;
  518. }
  519. static struct device_type bt_type = {
  520. .name = "bluetooth",
  521. };
  522. static void set_addr(u8 *eui, u8 *addr, u8 addr_type)
  523. {
  524. /* addr is the BT address in little-endian format */
  525. eui[0] = addr[5];
  526. eui[1] = addr[4];
  527. eui[2] = addr[3];
  528. eui[3] = 0xFF;
  529. eui[4] = 0xFE;
  530. eui[5] = addr[2];
  531. eui[6] = addr[1];
  532. eui[7] = addr[0];
  533. /* Universal/local bit set, BT 6lowpan draft ch. 3.2.1 */
  534. if (addr_type == BDADDR_LE_PUBLIC)
  535. eui[0] &= ~0x02;
  536. else
  537. eui[0] |= 0x02;
  538. BT_DBG("type %d addr %*phC", addr_type, 8, eui);
  539. }
  540. static void set_dev_addr(struct net_device *netdev, bdaddr_t *addr,
  541. u8 addr_type)
  542. {
  543. netdev->addr_assign_type = NET_ADDR_PERM;
  544. set_addr(netdev->dev_addr, addr->b, addr_type);
  545. }
  546. static void ifup(struct net_device *netdev)
  547. {
  548. int err;
  549. rtnl_lock();
  550. err = dev_open(netdev);
  551. if (err < 0)
  552. BT_INFO("iface %s cannot be opened (%d)", netdev->name, err);
  553. rtnl_unlock();
  554. }
  555. static void ifdown(struct net_device *netdev)
  556. {
  557. int err;
  558. rtnl_lock();
  559. err = dev_close(netdev);
  560. if (err < 0)
  561. BT_INFO("iface %s cannot be closed (%d)", netdev->name, err);
  562. rtnl_unlock();
  563. }
  564. static void do_notify_peers(struct work_struct *work)
  565. {
  566. struct lowpan_btle_dev *dev = container_of(work, struct lowpan_btle_dev,
  567. notify_peers.work);
  568. netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */
  569. }
  570. static bool is_bt_6lowpan(struct hci_conn *hcon)
  571. {
  572. if (hcon->type != LE_LINK)
  573. return false;
  574. if (!enable_6lowpan)
  575. return false;
  576. return true;
  577. }
  578. static struct l2cap_chan *chan_create(void)
  579. {
  580. struct l2cap_chan *chan;
  581. chan = l2cap_chan_create();
  582. if (!chan)
  583. return NULL;
  584. l2cap_chan_set_defaults(chan);
  585. chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
  586. chan->mode = L2CAP_MODE_LE_FLOWCTL;
  587. chan->imtu = 1280;
  588. return chan;
  589. }
  590. static void set_ip_addr_bits(u8 addr_type, u8 *addr)
  591. {
  592. if (addr_type == BDADDR_LE_PUBLIC)
  593. *addr |= 0x02;
  594. else
  595. *addr &= ~0x02;
  596. }
  597. static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
  598. struct lowpan_btle_dev *dev,
  599. bool new_netdev)
  600. {
  601. struct lowpan_peer *peer;
  602. peer = kzalloc(sizeof(*peer), GFP_ATOMIC);
  603. if (!peer)
  604. return NULL;
  605. peer->chan = chan;
  606. memset(&peer->peer_addr, 0, sizeof(struct in6_addr));
  607. /* RFC 2464 ch. 5 */
  608. peer->peer_addr.s6_addr[0] = 0xFE;
  609. peer->peer_addr.s6_addr[1] = 0x80;
  610. set_addr((u8 *)&peer->peer_addr.s6_addr + 8, chan->dst.b,
  611. chan->dst_type);
  612. memcpy(&peer->eui64_addr, (u8 *)&peer->peer_addr.s6_addr + 8,
  613. EUI64_ADDR_LEN);
  614. /* IPv6 address needs to have the U/L bit set properly so toggle
  615. * it back here.
  616. */
  617. set_ip_addr_bits(chan->dst_type, (u8 *)&peer->peer_addr.s6_addr + 8);
  618. spin_lock(&devices_lock);
  619. INIT_LIST_HEAD(&peer->list);
  620. peer_add(dev, peer);
  621. spin_unlock(&devices_lock);
  622. /* Notifying peers about us needs to be done without locks held */
  623. if (new_netdev)
  624. INIT_DELAYED_WORK(&dev->notify_peers, do_notify_peers);
  625. schedule_delayed_work(&dev->notify_peers, msecs_to_jiffies(100));
  626. return peer->chan;
  627. }
  628. static int setup_netdev(struct l2cap_chan *chan, struct lowpan_btle_dev **dev)
  629. {
  630. struct net_device *netdev;
  631. int err = 0;
  632. netdev = alloc_netdev(LOWPAN_PRIV_SIZE(sizeof(struct lowpan_btle_dev)),
  633. IFACE_NAME_TEMPLATE, NET_NAME_UNKNOWN,
  634. netdev_setup);
  635. if (!netdev)
  636. return -ENOMEM;
  637. set_dev_addr(netdev, &chan->src, chan->src_type);
  638. netdev->netdev_ops = &netdev_ops;
  639. SET_NETDEV_DEV(netdev, &chan->conn->hcon->hdev->dev);
  640. SET_NETDEV_DEVTYPE(netdev, &bt_type);
  641. *dev = lowpan_btle_dev(netdev);
  642. (*dev)->netdev = netdev;
  643. (*dev)->hdev = chan->conn->hcon->hdev;
  644. INIT_LIST_HEAD(&(*dev)->peers);
  645. spin_lock(&devices_lock);
  646. INIT_LIST_HEAD(&(*dev)->list);
  647. list_add_rcu(&(*dev)->list, &bt_6lowpan_devices);
  648. spin_unlock(&devices_lock);
  649. err = lowpan_register_netdev(netdev, LOWPAN_LLTYPE_BTLE);
  650. if (err < 0) {
  651. BT_INFO("register_netdev failed %d", err);
  652. spin_lock(&devices_lock);
  653. list_del_rcu(&(*dev)->list);
  654. spin_unlock(&devices_lock);
  655. free_netdev(netdev);
  656. goto out;
  657. }
  658. BT_DBG("ifindex %d peer bdaddr %pMR type %d my addr %pMR type %d",
  659. netdev->ifindex, &chan->dst, chan->dst_type,
  660. &chan->src, chan->src_type);
  661. set_bit(__LINK_STATE_PRESENT, &netdev->state);
  662. return 0;
  663. out:
  664. return err;
  665. }
  666. static inline void chan_ready_cb(struct l2cap_chan *chan)
  667. {
  668. struct lowpan_btle_dev *dev;
  669. bool new_netdev = false;
  670. dev = lookup_dev(chan->conn);
  671. BT_DBG("chan %p conn %p dev %p", chan, chan->conn, dev);
  672. if (!dev) {
  673. if (setup_netdev(chan, &dev) < 0) {
  674. l2cap_chan_del(chan, -ENOENT);
  675. return;
  676. }
  677. new_netdev = true;
  678. }
  679. if (!try_module_get(THIS_MODULE))
  680. return;
  681. add_peer_chan(chan, dev, new_netdev);
  682. ifup(dev->netdev);
  683. }
  684. static inline struct l2cap_chan *chan_new_conn_cb(struct l2cap_chan *pchan)
  685. {
  686. struct l2cap_chan *chan;
  687. chan = chan_create();
  688. if (!chan)
  689. return NULL;
  690. chan->ops = pchan->ops;
  691. BT_DBG("chan %p pchan %p", chan, pchan);
  692. return chan;
  693. }
  694. static void delete_netdev(struct work_struct *work)
  695. {
  696. struct lowpan_btle_dev *entry = container_of(work,
  697. struct lowpan_btle_dev,
  698. delete_netdev);
  699. lowpan_unregister_netdev(entry->netdev);
  700. /* The entry pointer is deleted by the netdev destructor. */
  701. }
  702. static void chan_close_cb(struct l2cap_chan *chan)
  703. {
  704. struct lowpan_btle_dev *entry;
  705. struct lowpan_btle_dev *dev = NULL;
  706. struct lowpan_peer *peer;
  707. int err = -ENOENT;
  708. bool last = false, remove = true;
  709. BT_DBG("chan %p conn %p", chan, chan->conn);
  710. if (chan->conn && chan->conn->hcon) {
  711. if (!is_bt_6lowpan(chan->conn->hcon))
  712. return;
  713. /* If conn is set, then the netdev is also there and we should
  714. * not remove it.
  715. */
  716. remove = false;
  717. }
  718. spin_lock(&devices_lock);
  719. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  720. dev = lowpan_btle_dev(entry->netdev);
  721. peer = __peer_lookup_chan(dev, chan);
  722. if (peer) {
  723. last = peer_del(dev, peer);
  724. err = 0;
  725. BT_DBG("dev %p removing %speer %p", dev,
  726. last ? "last " : "1 ", peer);
  727. BT_DBG("chan %p orig refcnt %d", chan,
  728. atomic_read(&chan->kref.refcount));
  729. l2cap_chan_put(chan);
  730. break;
  731. }
  732. }
  733. if (!err && last && dev && !atomic_read(&dev->peer_count)) {
  734. spin_unlock(&devices_lock);
  735. cancel_delayed_work_sync(&dev->notify_peers);
  736. ifdown(dev->netdev);
  737. if (remove) {
  738. INIT_WORK(&entry->delete_netdev, delete_netdev);
  739. schedule_work(&entry->delete_netdev);
  740. }
  741. } else {
  742. spin_unlock(&devices_lock);
  743. }
  744. return;
  745. }
  746. static void chan_state_change_cb(struct l2cap_chan *chan, int state, int err)
  747. {
  748. BT_DBG("chan %p conn %p state %s err %d", chan, chan->conn,
  749. state_to_string(state), err);
  750. }
  751. static struct sk_buff *chan_alloc_skb_cb(struct l2cap_chan *chan,
  752. unsigned long hdr_len,
  753. unsigned long len, int nb)
  754. {
  755. /* Note that we must allocate using GFP_ATOMIC here as
  756. * this function is called originally from netdev hard xmit
  757. * function in atomic context.
  758. */
  759. return bt_skb_alloc(hdr_len + len, GFP_ATOMIC);
  760. }
  761. static void chan_suspend_cb(struct l2cap_chan *chan)
  762. {
  763. struct sk_buff *skb = chan->data;
  764. BT_DBG("chan %p conn %p skb %p", chan, chan->conn, skb);
  765. if (!skb)
  766. return;
  767. lowpan_cb(skb)->status = -EAGAIN;
  768. }
  769. static void chan_resume_cb(struct l2cap_chan *chan)
  770. {
  771. struct sk_buff *skb = chan->data;
  772. BT_DBG("chan %p conn %p skb %p", chan, chan->conn, skb);
  773. if (!skb)
  774. return;
  775. lowpan_cb(skb)->status = 0;
  776. }
  777. static long chan_get_sndtimeo_cb(struct l2cap_chan *chan)
  778. {
  779. return L2CAP_CONN_TIMEOUT;
  780. }
  781. static const struct l2cap_ops bt_6lowpan_chan_ops = {
  782. .name = "L2CAP 6LoWPAN channel",
  783. .new_connection = chan_new_conn_cb,
  784. .recv = chan_recv_cb,
  785. .close = chan_close_cb,
  786. .state_change = chan_state_change_cb,
  787. .ready = chan_ready_cb,
  788. .resume = chan_resume_cb,
  789. .suspend = chan_suspend_cb,
  790. .get_sndtimeo = chan_get_sndtimeo_cb,
  791. .alloc_skb = chan_alloc_skb_cb,
  792. .teardown = l2cap_chan_no_teardown,
  793. .defer = l2cap_chan_no_defer,
  794. .set_shutdown = l2cap_chan_no_set_shutdown,
  795. };
  796. static inline __u8 bdaddr_type(__u8 type)
  797. {
  798. if (type == ADDR_LE_DEV_PUBLIC)
  799. return BDADDR_LE_PUBLIC;
  800. else
  801. return BDADDR_LE_RANDOM;
  802. }
  803. static int bt_6lowpan_connect(bdaddr_t *addr, u8 dst_type)
  804. {
  805. struct l2cap_chan *chan;
  806. int err;
  807. chan = chan_create();
  808. if (!chan)
  809. return -EINVAL;
  810. chan->ops = &bt_6lowpan_chan_ops;
  811. err = l2cap_chan_connect(chan, cpu_to_le16(L2CAP_PSM_IPSP), 0,
  812. addr, dst_type);
  813. BT_DBG("chan %p err %d", chan, err);
  814. if (err < 0)
  815. l2cap_chan_put(chan);
  816. return err;
  817. }
  818. static int bt_6lowpan_disconnect(struct l2cap_conn *conn, u8 dst_type)
  819. {
  820. struct lowpan_peer *peer;
  821. BT_DBG("conn %p dst type %d", conn, dst_type);
  822. peer = lookup_peer(conn);
  823. if (!peer)
  824. return -ENOENT;
  825. BT_DBG("peer %p chan %p", peer, peer->chan);
  826. l2cap_chan_close(peer->chan, ENOENT);
  827. return 0;
  828. }
  829. static struct l2cap_chan *bt_6lowpan_listen(void)
  830. {
  831. bdaddr_t *addr = BDADDR_ANY;
  832. struct l2cap_chan *chan;
  833. int err;
  834. if (!enable_6lowpan)
  835. return NULL;
  836. chan = chan_create();
  837. if (!chan)
  838. return NULL;
  839. chan->ops = &bt_6lowpan_chan_ops;
  840. chan->state = BT_LISTEN;
  841. chan->src_type = BDADDR_LE_PUBLIC;
  842. atomic_set(&chan->nesting, L2CAP_NESTING_PARENT);
  843. BT_DBG("chan %p src type %d", chan, chan->src_type);
  844. err = l2cap_add_psm(chan, addr, cpu_to_le16(L2CAP_PSM_IPSP));
  845. if (err) {
  846. l2cap_chan_put(chan);
  847. BT_ERR("psm cannot be added err %d", err);
  848. return NULL;
  849. }
  850. return chan;
  851. }
  852. static int get_l2cap_conn(char *buf, bdaddr_t *addr, u8 *addr_type,
  853. struct l2cap_conn **conn)
  854. {
  855. struct hci_conn *hcon;
  856. struct hci_dev *hdev;
  857. int n;
  858. n = sscanf(buf, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx %hhu",
  859. &addr->b[5], &addr->b[4], &addr->b[3],
  860. &addr->b[2], &addr->b[1], &addr->b[0],
  861. addr_type);
  862. if (n < 7)
  863. return -EINVAL;
  864. /* The LE_PUBLIC address type is ignored because of BDADDR_ANY */
  865. hdev = hci_get_route(addr, BDADDR_ANY, BDADDR_LE_PUBLIC);
  866. if (!hdev)
  867. return -ENOENT;
  868. hci_dev_lock(hdev);
  869. hcon = hci_conn_hash_lookup_le(hdev, addr, *addr_type);
  870. hci_dev_unlock(hdev);
  871. if (!hcon)
  872. return -ENOENT;
  873. *conn = (struct l2cap_conn *)hcon->l2cap_data;
  874. BT_DBG("conn %p dst %pMR type %d", *conn, &hcon->dst, hcon->dst_type);
  875. return 0;
  876. }
  877. static void disconnect_all_peers(void)
  878. {
  879. struct lowpan_btle_dev *entry;
  880. struct lowpan_peer *peer, *tmp_peer, *new_peer;
  881. struct list_head peers;
  882. INIT_LIST_HEAD(&peers);
  883. /* We make a separate list of peers as the close_cb() will
  884. * modify the device peers list so it is better not to mess
  885. * with the same list at the same time.
  886. */
  887. rcu_read_lock();
  888. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  889. list_for_each_entry_rcu(peer, &entry->peers, list) {
  890. new_peer = kmalloc(sizeof(*new_peer), GFP_ATOMIC);
  891. if (!new_peer)
  892. break;
  893. new_peer->chan = peer->chan;
  894. INIT_LIST_HEAD(&new_peer->list);
  895. list_add(&new_peer->list, &peers);
  896. }
  897. }
  898. rcu_read_unlock();
  899. spin_lock(&devices_lock);
  900. list_for_each_entry_safe(peer, tmp_peer, &peers, list) {
  901. l2cap_chan_close(peer->chan, ENOENT);
  902. list_del_rcu(&peer->list);
  903. kfree_rcu(peer, rcu);
  904. }
  905. spin_unlock(&devices_lock);
  906. }
  907. struct set_enable {
  908. struct work_struct work;
  909. bool flag;
  910. };
  911. static void do_enable_set(struct work_struct *work)
  912. {
  913. struct set_enable *set_enable = container_of(work,
  914. struct set_enable, work);
  915. if (!set_enable->flag || enable_6lowpan != set_enable->flag)
  916. /* Disconnect existing connections if 6lowpan is
  917. * disabled
  918. */
  919. disconnect_all_peers();
  920. enable_6lowpan = set_enable->flag;
  921. if (listen_chan) {
  922. l2cap_chan_close(listen_chan, 0);
  923. l2cap_chan_put(listen_chan);
  924. }
  925. listen_chan = bt_6lowpan_listen();
  926. kfree(set_enable);
  927. }
  928. static int lowpan_enable_set(void *data, u64 val)
  929. {
  930. struct set_enable *set_enable;
  931. set_enable = kzalloc(sizeof(*set_enable), GFP_KERNEL);
  932. if (!set_enable)
  933. return -ENOMEM;
  934. set_enable->flag = !!val;
  935. INIT_WORK(&set_enable->work, do_enable_set);
  936. schedule_work(&set_enable->work);
  937. return 0;
  938. }
  939. static int lowpan_enable_get(void *data, u64 *val)
  940. {
  941. *val = enable_6lowpan;
  942. return 0;
  943. }
  944. DEFINE_SIMPLE_ATTRIBUTE(lowpan_enable_fops, lowpan_enable_get,
  945. lowpan_enable_set, "%llu\n");
  946. static ssize_t lowpan_control_write(struct file *fp,
  947. const char __user *user_buffer,
  948. size_t count,
  949. loff_t *position)
  950. {
  951. char buf[32];
  952. size_t buf_size = min(count, sizeof(buf) - 1);
  953. int ret;
  954. bdaddr_t addr;
  955. u8 addr_type;
  956. struct l2cap_conn *conn = NULL;
  957. if (copy_from_user(buf, user_buffer, buf_size))
  958. return -EFAULT;
  959. buf[buf_size] = '\0';
  960. if (memcmp(buf, "connect ", 8) == 0) {
  961. ret = get_l2cap_conn(&buf[8], &addr, &addr_type, &conn);
  962. if (ret == -EINVAL)
  963. return ret;
  964. if (listen_chan) {
  965. l2cap_chan_close(listen_chan, 0);
  966. l2cap_chan_put(listen_chan);
  967. listen_chan = NULL;
  968. }
  969. if (conn) {
  970. struct lowpan_peer *peer;
  971. if (!is_bt_6lowpan(conn->hcon))
  972. return -EINVAL;
  973. peer = lookup_peer(conn);
  974. if (peer) {
  975. BT_DBG("6LoWPAN connection already exists");
  976. return -EALREADY;
  977. }
  978. BT_DBG("conn %p dst %pMR type %d user %d", conn,
  979. &conn->hcon->dst, conn->hcon->dst_type,
  980. addr_type);
  981. }
  982. ret = bt_6lowpan_connect(&addr, addr_type);
  983. if (ret < 0)
  984. return ret;
  985. return count;
  986. }
  987. if (memcmp(buf, "disconnect ", 11) == 0) {
  988. ret = get_l2cap_conn(&buf[11], &addr, &addr_type, &conn);
  989. if (ret < 0)
  990. return ret;
  991. ret = bt_6lowpan_disconnect(conn, addr_type);
  992. if (ret < 0)
  993. return ret;
  994. return count;
  995. }
  996. return count;
  997. }
  998. static int lowpan_control_show(struct seq_file *f, void *ptr)
  999. {
  1000. struct lowpan_btle_dev *entry;
  1001. struct lowpan_peer *peer;
  1002. spin_lock(&devices_lock);
  1003. list_for_each_entry(entry, &bt_6lowpan_devices, list) {
  1004. list_for_each_entry(peer, &entry->peers, list)
  1005. seq_printf(f, "%pMR (type %u)\n",
  1006. &peer->chan->dst, peer->chan->dst_type);
  1007. }
  1008. spin_unlock(&devices_lock);
  1009. return 0;
  1010. }
  1011. static int lowpan_control_open(struct inode *inode, struct file *file)
  1012. {
  1013. return single_open(file, lowpan_control_show, inode->i_private);
  1014. }
  1015. static const struct file_operations lowpan_control_fops = {
  1016. .open = lowpan_control_open,
  1017. .read = seq_read,
  1018. .write = lowpan_control_write,
  1019. .llseek = seq_lseek,
  1020. .release = single_release,
  1021. };
  1022. static void disconnect_devices(void)
  1023. {
  1024. struct lowpan_btle_dev *entry, *tmp, *new_dev;
  1025. struct list_head devices;
  1026. INIT_LIST_HEAD(&devices);
  1027. /* We make a separate list of devices because the unregister_netdev()
  1028. * will call device_event() which will also want to modify the same
  1029. * devices list.
  1030. */
  1031. rcu_read_lock();
  1032. list_for_each_entry_rcu(entry, &bt_6lowpan_devices, list) {
  1033. new_dev = kmalloc(sizeof(*new_dev), GFP_ATOMIC);
  1034. if (!new_dev)
  1035. break;
  1036. new_dev->netdev = entry->netdev;
  1037. INIT_LIST_HEAD(&new_dev->list);
  1038. list_add_rcu(&new_dev->list, &devices);
  1039. }
  1040. rcu_read_unlock();
  1041. list_for_each_entry_safe(entry, tmp, &devices, list) {
  1042. ifdown(entry->netdev);
  1043. BT_DBG("Unregistering netdev %s %p",
  1044. entry->netdev->name, entry->netdev);
  1045. lowpan_unregister_netdev(entry->netdev);
  1046. kfree(entry);
  1047. }
  1048. }
  1049. static int device_event(struct notifier_block *unused,
  1050. unsigned long event, void *ptr)
  1051. {
  1052. struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
  1053. struct lowpan_btle_dev *entry;
  1054. if (netdev->type != ARPHRD_6LOWPAN)
  1055. return NOTIFY_DONE;
  1056. switch (event) {
  1057. case NETDEV_UNREGISTER:
  1058. spin_lock(&devices_lock);
  1059. list_for_each_entry(entry, &bt_6lowpan_devices, list) {
  1060. if (entry->netdev == netdev) {
  1061. BT_DBG("Unregistered netdev %s %p",
  1062. netdev->name, netdev);
  1063. list_del(&entry->list);
  1064. break;
  1065. }
  1066. }
  1067. spin_unlock(&devices_lock);
  1068. break;
  1069. }
  1070. return NOTIFY_DONE;
  1071. }
  1072. static struct notifier_block bt_6lowpan_dev_notifier = {
  1073. .notifier_call = device_event,
  1074. };
  1075. static int __init bt_6lowpan_init(void)
  1076. {
  1077. lowpan_enable_debugfs = debugfs_create_file("6lowpan_enable", 0644,
  1078. bt_debugfs, NULL,
  1079. &lowpan_enable_fops);
  1080. lowpan_control_debugfs = debugfs_create_file("6lowpan_control", 0644,
  1081. bt_debugfs, NULL,
  1082. &lowpan_control_fops);
  1083. return register_netdevice_notifier(&bt_6lowpan_dev_notifier);
  1084. }
  1085. static void __exit bt_6lowpan_exit(void)
  1086. {
  1087. debugfs_remove(lowpan_enable_debugfs);
  1088. debugfs_remove(lowpan_control_debugfs);
  1089. if (listen_chan) {
  1090. l2cap_chan_close(listen_chan, 0);
  1091. l2cap_chan_put(listen_chan);
  1092. }
  1093. disconnect_devices();
  1094. unregister_netdevice_notifier(&bt_6lowpan_dev_notifier);
  1095. }
  1096. module_init(bt_6lowpan_init);
  1097. module_exit(bt_6lowpan_exit);
  1098. MODULE_AUTHOR("Jukka Rissanen <[email protected]>");
  1099. MODULE_DESCRIPTION("Bluetooth 6LoWPAN");
  1100. MODULE_VERSION(VERSION);
  1101. MODULE_LICENSE("GPL");