1#ifndef LLC_H
2#define LLC_H
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/if.h>
16#include <linux/if_ether.h>
17#include <linux/list.h>
18#include <linux/spinlock.h>
19
20#include <asm/atomic.h>
21
22struct net_device;
23struct packet_type;
24struct sk_buff;
25
26struct 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
36
37
38
39
40
41
42
43
44
45struct llc_sap {
46 unsigned char state;
47 unsigned char p_bit;
48 unsigned char f_bit;
49 atomic_t refcnt;
50 int (*rcv_func)(struct sk_buff *skb,
51 struct net_device *dev,
52 struct packet_type *pt,
53 struct net_device *orig_dev);
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
63#define LLC_DEST_SAP 1
64#define LLC_DEST_CONN 2
65
66extern struct list_head llc_sap_list;
67extern rwlock_t llc_sap_list_lock;
68extern unsigned char llc_station_mac_sa[ETH_ALEN];
69
70extern int llc_rcv(struct sk_buff *skb, struct net_device *dev,
71 struct packet_type *pt, struct net_device *orig_dev);
72
73extern int llc_mac_hdr_init(struct sk_buff *skb,
74 const unsigned char *sa, const unsigned char *da);
75
76extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
77 struct sk_buff *skb));
78extern void llc_remove_pack(int type);
79
80extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
81
82extern struct llc_sap *llc_sap_open(unsigned char lsap,
83 int (*rcv)(struct sk_buff *skb,
84 struct net_device *dev,
85 struct packet_type *pt,
86 struct net_device *orig_dev));
87static inline void llc_sap_hold(struct llc_sap *sap)
88{
89 atomic_inc(&sap->refcnt);
90}
91
92extern void llc_sap_close(struct llc_sap *sap);
93
94static inline void llc_sap_put(struct llc_sap *sap)
95{
96 if (atomic_dec_and_test(&sap->refcnt))
97 llc_sap_close(sap);
98}
99
100extern struct llc_sap *llc_sap_find(unsigned char sap_value);
101
102extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
103 unsigned char *dmac, unsigned char dsap);
104
105extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
106extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
107
108extern int llc_station_init(void);
109extern void llc_station_exit(void);
110
111#ifdef CONFIG_PROC_FS
112extern int llc_proc_init(void);
113extern void llc_proc_exit(void);
114#else
115#define llc_proc_init() (0)
116#define llc_proc_exit() do { } while(0)
117#endif
118#ifdef CONFIG_SYSCTL
119extern int llc_sysctl_init(void);
120extern void llc_sysctl_exit(void);
121
122extern int sysctl_llc2_ack_timeout;
123extern int sysctl_llc2_busy_timeout;
124extern int sysctl_llc2_p_timeout;
125extern int sysctl_llc2_rej_timeout;
126extern int sysctl_llc_station_ack_timeout;
127#else
128#define llc_sysctl_init() (0)
129#define llc_sysctl_exit() do { } while(0)
130#endif
131#endif
132