p8022.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * NET3: Support for 802.2 demultiplexing off Ethernet
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of the GNU General Public License
  5. * as published by the Free Software Foundation; either version
  6. * 2 of the License, or (at your option) any later version.
  7. *
  8. * Demultiplex 802.2 encoded protocols. We match the entry by the
  9. * SSAP/DSAP pair and then deliver to the registered datalink that
  10. * matches. The control byte is ignored and handling of such items
  11. * is up to the routine passed the frame.
  12. *
  13. * Unlike the 802.3 datalink we have a list of 802.2 entries as
  14. * there are multiple protocols to demux. The list is currently
  15. * short (3 or 4 entries at most). The current demux assumes this.
  16. */
  17. #include <linux/module.h>
  18. #include <linux/netdevice.h>
  19. #include <linux/skbuff.h>
  20. #include <linux/slab.h>
  21. #include <net/datalink.h>
  22. #include <linux/mm.h>
  23. #include <linux/in.h>
  24. #include <linux/init.h>
  25. #include <net/llc.h>
  26. #include <net/p8022.h>
  27. static int p8022_request(struct datalink_proto *dl, struct sk_buff *skb,
  28. unsigned char *dest)
  29. {
  30. llc_build_and_send_ui_pkt(dl->sap, skb, dest, dl->sap->laddr.lsap);
  31. return 0;
  32. }
  33. struct datalink_proto *register_8022_client(unsigned char type,
  34. int (*func)(struct sk_buff *skb,
  35. struct net_device *dev,
  36. struct packet_type *pt,
  37. struct net_device *orig_dev))
  38. {
  39. struct datalink_proto *proto;
  40. proto = kmalloc(sizeof(*proto), GFP_ATOMIC);
  41. if (proto) {
  42. proto->type[0] = type;
  43. proto->header_length = 3;
  44. proto->request = p8022_request;
  45. proto->sap = llc_sap_open(type, func);
  46. if (!proto->sap) {
  47. kfree(proto);
  48. proto = NULL;
  49. }
  50. }
  51. return proto;
  52. }
  53. void unregister_8022_client(struct datalink_proto *proto)
  54. {
  55. llc_sap_put(proto->sap);
  56. kfree(proto);
  57. }
  58. EXPORT_SYMBOL(register_8022_client);
  59. EXPORT_SYMBOL(unregister_8022_client);
  60. MODULE_LICENSE("GPL");