Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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 | |
| 15 | #include <linux/if.h> |
| 16 | #include <linux/if_ether.h> |
| 17 | #include <linux/list.h> |
| 18 | #include <linux/spinlock.h> |
| 19 | |
Arnaldo Carvalho de Melo | 6e2144b | 2005-09-22 04:43:05 -0300 | [diff] [blame] | 20 | #include <asm/atomic.h> |
| 21 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 22 | struct net_device; |
| 23 | struct packet_type; |
| 24 | struct sk_buff; |
| 25 | |
| 26 | struct llc_addr { |
| 27 | unsigned char lsap; |
| 28 | unsigned char mac[IFHWADDRLEN]; |
| 29 | }; |
| 30 | |
| 31 | #define LLC_SAP_STATE_INACTIVE 1 |
| 32 | #define LLC_SAP_STATE_ACTIVE 2 |
| 33 | |
| 34 | /** |
| 35 | * struct llc_sap - Defines the SAP component |
| 36 | * |
| 37 | * @station - station this sap belongs to |
| 38 | * @state - sap state |
| 39 | * @p_bit - only lowest-order bit used |
| 40 | * @f_bit - only lowest-order bit used |
| 41 | * @laddr - SAP value in this 'lsap' |
| 42 | * @node - entry in station sap_list |
| 43 | * @sk_list - LLC sockets this one manages |
| 44 | */ |
| 45 | struct llc_sap { |
| 46 | unsigned char state; |
| 47 | unsigned char p_bit; |
| 48 | unsigned char f_bit; |
Arnaldo Carvalho de Melo | 6e2144b | 2005-09-22 04:43:05 -0300 | [diff] [blame] | 49 | atomic_t refcnt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int (*rcv_func)(struct sk_buff *skb, |
| 51 | struct net_device *dev, |
David S. Miller | f2ccd8f | 2005-08-09 19:34:12 -0700 | [diff] [blame] | 52 | struct packet_type *pt, |
| 53 | struct net_device *orig_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | struct llc_addr laddr; |
| 55 | struct list_head node; |
| 56 | struct { |
| 57 | rwlock_t lock; |
| 58 | struct hlist_head list; |
| 59 | } sk_list; |
| 60 | }; |
| 61 | |
| 62 | #define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */ |
| 63 | #define LLC_DEST_SAP 1 /* Type 1 goes here */ |
| 64 | #define LLC_DEST_CONN 2 /* Type 2 goes here */ |
| 65 | |
| 66 | extern struct list_head llc_sap_list; |
| 67 | extern rwlock_t llc_sap_list_lock; |
| 68 | extern unsigned char llc_station_mac_sa[ETH_ALEN]; |
| 69 | |
| 70 | extern int llc_rcv(struct sk_buff *skb, struct net_device *dev, |
David S. Miller | f2ccd8f | 2005-08-09 19:34:12 -0700 | [diff] [blame] | 71 | struct packet_type *pt, struct net_device *orig_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | extern int llc_mac_hdr_init(struct sk_buff *skb, |
Stephen Hemminger | f4ad2b1 | 2006-03-20 22:59:36 -0800 | [diff] [blame] | 74 | const unsigned char *sa, const unsigned char *da); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | |
| 76 | extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap, |
| 77 | struct sk_buff *skb)); |
| 78 | extern void llc_remove_pack(int type); |
| 79 | |
| 80 | extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb)); |
| 81 | |
| 82 | extern struct llc_sap *llc_sap_open(unsigned char lsap, |
| 83 | int (*rcv)(struct sk_buff *skb, |
| 84 | struct net_device *dev, |
David S. Miller | f2ccd8f | 2005-08-09 19:34:12 -0700 | [diff] [blame] | 85 | struct packet_type *pt, |
| 86 | struct net_device *orig_dev)); |
Arnaldo Carvalho de Melo | 6e2144b | 2005-09-22 04:43:05 -0300 | [diff] [blame] | 87 | static inline void llc_sap_hold(struct llc_sap *sap) |
| 88 | { |
| 89 | atomic_inc(&sap->refcnt); |
| 90 | } |
| 91 | |
Arnaldo Carvalho de Melo | 2928c19 | 2005-09-22 05:14:33 -0300 | [diff] [blame] | 92 | extern void llc_sap_close(struct llc_sap *sap); |
| 93 | |
Arnaldo Carvalho de Melo | 6e2144b | 2005-09-22 04:43:05 -0300 | [diff] [blame] | 94 | static inline void llc_sap_put(struct llc_sap *sap) |
| 95 | { |
Arnaldo Carvalho de Melo | 6e2144b | 2005-09-22 04:43:05 -0300 | [diff] [blame] | 96 | if (atomic_dec_and_test(&sap->refcnt)) |
| 97 | llc_sap_close(sap); |
| 98 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | extern struct llc_sap *llc_sap_find(unsigned char sap_value); |
| 101 | |
| 102 | extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, |
| 103 | unsigned char *dmac, unsigned char dsap); |
| 104 | |
Arnaldo Carvalho de Melo | 2928c19 | 2005-09-22 05:14:33 -0300 | [diff] [blame] | 105 | extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); |
| 106 | extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); |
| 107 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | extern int llc_station_init(void); |
| 109 | extern void llc_station_exit(void); |
| 110 | |
| 111 | #ifdef CONFIG_PROC_FS |
| 112 | extern int llc_proc_init(void); |
| 113 | extern void llc_proc_exit(void); |
| 114 | #else |
| 115 | #define llc_proc_init() (0) |
| 116 | #define llc_proc_exit() do { } while(0) |
| 117 | #endif /* CONFIG_PROC_FS */ |
Arnaldo Carvalho de Melo | 590232a | 2005-09-22 04:30:44 -0300 | [diff] [blame] | 118 | #ifdef CONFIG_SYSCTL |
| 119 | extern int llc_sysctl_init(void); |
| 120 | extern void llc_sysctl_exit(void); |
Arnaldo Carvalho de Melo | 2928c19 | 2005-09-22 05:14:33 -0300 | [diff] [blame] | 121 | |
| 122 | extern int sysctl_llc2_ack_timeout; |
| 123 | extern int sysctl_llc2_busy_timeout; |
| 124 | extern int sysctl_llc2_p_timeout; |
| 125 | extern int sysctl_llc2_rej_timeout; |
| 126 | extern int sysctl_llc_station_ack_timeout; |
Arnaldo Carvalho de Melo | 590232a | 2005-09-22 04:30:44 -0300 | [diff] [blame] | 127 | #else |
| 128 | #define llc_sysctl_init() (0) |
| 129 | #define llc_sysctl_exit() do { } while(0) |
| 130 | #endif /* CONFIG_SYSCTL */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | #endif /* LLC_H */ |