6lowpan.txt 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. Netdev private dataroom for 6lowpan interfaces:
  2. All 6lowpan able net devices, means all interfaces with ARPHRD_6LOWPAN,
  3. must have "struct lowpan_priv" placed at beginning of netdev_priv.
  4. The priv_size of each interface should be calculate by:
  5. dev->priv_size = LOWPAN_PRIV_SIZE(LL_6LOWPAN_PRIV_DATA);
  6. Where LL_PRIV_6LOWPAN_DATA is sizeof linklayer 6lowpan private data struct.
  7. To access the LL_PRIV_6LOWPAN_DATA structure you can cast:
  8. lowpan_priv(dev)-priv;
  9. to your LL_6LOWPAN_PRIV_DATA structure.
  10. Before registering the lowpan netdev interface you must run:
  11. lowpan_netdev_setup(dev, LOWPAN_LLTYPE_FOOBAR);
  12. wheres LOWPAN_LLTYPE_FOOBAR is a define for your 6LoWPAN linklayer type of
  13. enum lowpan_lltypes.
  14. Example to evaluate the private usually you can do:
  15. static inline sturct lowpan_priv_foobar *
  16. lowpan_foobar_priv(struct net_device *dev)
  17. {
  18. return (sturct lowpan_priv_foobar *)lowpan_priv(dev)->priv;
  19. }
  20. switch (dev->type) {
  21. case ARPHRD_6LOWPAN:
  22. lowpan_priv = lowpan_priv(dev);
  23. /* do great stuff which is ARPHRD_6LOWPAN related */
  24. switch (lowpan_priv->lltype) {
  25. case LOWPAN_LLTYPE_FOOBAR:
  26. /* do 802.15.4 6LoWPAN handling here */
  27. lowpan_foobar_priv(dev)->bar = foo;
  28. break;
  29. ...
  30. }
  31. break;
  32. ...
  33. }
  34. In case of generic 6lowpan branch ("net/6lowpan") you can remove the check
  35. on ARPHRD_6LOWPAN, because you can be sure that these function are called
  36. by ARPHRD_6LOWPAN interfaces.