llc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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 unsigned char llc_station_mac_sa[ETH_ALEN];
  61. extern int llc_rcv(struct sk_buff *skb, struct net_device *dev,
  62. struct packet_type *pt, struct net_device *orig_dev);
  63. extern int llc_mac_hdr_init(struct sk_buff *skb,
  64. const unsigned char *sa, const unsigned char *da);
  65. extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
  66. struct sk_buff *skb));
  67. extern void llc_remove_pack(int type);
  68. extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
  69. extern struct llc_sap *llc_sap_open(unsigned char lsap,
  70. int (*rcv)(struct sk_buff *skb,
  71. struct net_device *dev,
  72. struct packet_type *pt,
  73. struct net_device *orig_dev));
  74. static inline void llc_sap_hold(struct llc_sap *sap)
  75. {
  76. atomic_inc(&sap->refcnt);
  77. }
  78. extern void llc_sap_close(struct llc_sap *sap);
  79. static inline void llc_sap_put(struct llc_sap *sap)
  80. {
  81. if (atomic_dec_and_test(&sap->refcnt))
  82. llc_sap_close(sap);
  83. }
  84. extern struct llc_sap *llc_sap_find(unsigned char sap_value);
  85. extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
  86. unsigned char *dmac, unsigned char dsap);
  87. extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
  88. extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
  89. extern int llc_station_init(void);
  90. extern void llc_station_exit(void);
  91. #ifdef CONFIG_PROC_FS
  92. extern int llc_proc_init(void);
  93. extern void llc_proc_exit(void);
  94. #else
  95. #define llc_proc_init() (0)
  96. #define llc_proc_exit() do { } while(0)
  97. #endif /* CONFIG_PROC_FS */
  98. #ifdef CONFIG_SYSCTL
  99. extern int llc_sysctl_init(void);
  100. extern void llc_sysctl_exit(void);
  101. extern int sysctl_llc2_ack_timeout;
  102. extern int sysctl_llc2_busy_timeout;
  103. extern int sysctl_llc2_p_timeout;
  104. extern int sysctl_llc2_rej_timeout;
  105. extern int sysctl_llc_station_ack_timeout;
  106. #else
  107. #define llc_sysctl_init() (0)
  108. #define llc_sysctl_exit() do { } while(0)
  109. #endif /* CONFIG_SYSCTL */
  110. #endif /* LLC_H */