llc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #ifndef LLC_H
  2. #define LLC_H
  3. /*
  4. * Copyright (c) 1997 by Procom Technology, Inc.
  5. * 2001-2003 by Arnaldo Carvalho de Melo <acme@conectiva.com.br>
  6. *
  7. * This program can be redistributed or modified under the terms of the
  8. * GNU General Public License as published by the Free Software Foundation.
  9. * This program is distributed without any warranty or implied warranty
  10. * of merchantability or fitness for a particular purpose.
  11. *
  12. * See the GNU General Public License for more details.
  13. */
  14. #include <linux/if.h>
  15. #include <linux/if_ether.h>
  16. #include <linux/list.h>
  17. #include <linux/spinlock.h>
  18. #include <asm/atomic.h>
  19. struct net_device;
  20. struct packet_type;
  21. struct sk_buff;
  22. struct llc_addr {
  23. unsigned char lsap;
  24. unsigned char mac[IFHWADDRLEN];
  25. };
  26. #define LLC_SAP_STATE_INACTIVE 1
  27. #define LLC_SAP_STATE_ACTIVE 2
  28. /**
  29. * struct llc_sap - Defines the SAP component
  30. *
  31. * @station - station this sap belongs to
  32. * @state - sap state
  33. * @p_bit - only lowest-order bit used
  34. * @f_bit - only lowest-order bit used
  35. * @laddr - SAP value in this 'lsap'
  36. * @node - entry in station sap_list
  37. * @sk_list - LLC sockets this one manages
  38. */
  39. struct llc_sap {
  40. unsigned char state;
  41. unsigned char p_bit;
  42. unsigned char f_bit;
  43. atomic_t refcnt;
  44. int (*rcv_func)(struct sk_buff *skb,
  45. struct net_device *dev,
  46. struct packet_type *pt,
  47. struct net_device *orig_dev);
  48. struct llc_addr laddr;
  49. struct list_head node;
  50. struct {
  51. rwlock_t lock;
  52. struct hlist_head list;
  53. } sk_list;
  54. };
  55. #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */
  56. #define LLC_DEST_SAP 1 /* Type 1 goes here */
  57. #define LLC_DEST_CONN 2 /* Type 2 goes here */
  58. extern struct list_head llc_sap_list;
  59. extern rwlock_t llc_sap_list_lock;
  60. extern int llc_rcv(struct sk_buff *skb, struct net_device *dev,
  61. struct packet_type *pt, struct net_device *orig_dev);
  62. extern int llc_mac_hdr_init(struct sk_buff *skb,
  63. const unsigned char *sa, const unsigned char *da);
  64. extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
  65. struct sk_buff *skb));
  66. extern void llc_remove_pack(int type);
  67. extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
  68. extern struct llc_sap *llc_sap_open(unsigned char lsap,
  69. int (*rcv)(struct sk_buff *skb,
  70. struct net_device *dev,
  71. struct packet_type *pt,
  72. struct net_device *orig_dev));
  73. static inline void llc_sap_hold(struct llc_sap *sap)
  74. {
  75. atomic_inc(&sap->refcnt);
  76. }
  77. extern void llc_sap_close(struct llc_sap *sap);
  78. static inline void llc_sap_put(struct llc_sap *sap)
  79. {
  80. if (atomic_dec_and_test(&sap->refcnt))
  81. llc_sap_close(sap);
  82. }
  83. extern struct llc_sap *llc_sap_find(unsigned char sap_value);
  84. extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
  85. unsigned char *dmac, unsigned char dsap);
  86. extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
  87. extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
  88. extern int llc_station_init(void);
  89. extern void llc_station_exit(void);
  90. #ifdef CONFIG_PROC_FS
  91. extern int llc_proc_init(void);
  92. extern void llc_proc_exit(void);
  93. #else
  94. #define llc_proc_init() (0)
  95. #define llc_proc_exit() do { } while(0)
  96. #endif /* CONFIG_PROC_FS */
  97. #ifdef CONFIG_SYSCTL
  98. extern int llc_sysctl_init(void);
  99. extern void llc_sysctl_exit(void);
  100. extern int sysctl_llc2_ack_timeout;
  101. extern int sysctl_llc2_busy_timeout;
  102. extern int sysctl_llc2_p_timeout;
  103. extern int sysctl_llc2_rej_timeout;
  104. extern int sysctl_llc_station_ack_timeout;
  105. #else
  106. #define llc_sysctl_init() (0)
  107. #define llc_sysctl_exit() do { } while(0)
  108. #endif /* CONFIG_SYSCTL */
  109. #endif /* LLC_H */