blob: 1559cf10e8747acb3bbb87806db80a5b4076292d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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>
Octavian Purdilab76f5a82009-12-26 11:51:02 +000019#include <linux/rculist_nulls.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030021#include <asm/atomic.h>
22
Linus Torvalds1da177e2005-04-16 15:20:36 -070023struct net_device;
24struct packet_type;
25struct sk_buff;
26
27struct llc_addr {
28 unsigned char lsap;
29 unsigned char mac[IFHWADDRLEN];
30};
31
32#define LLC_SAP_STATE_INACTIVE 1
33#define LLC_SAP_STATE_ACTIVE 2
34
35/**
36 * struct llc_sap - Defines the SAP component
37 *
38 * @station - station this sap belongs to
39 * @state - sap state
40 * @p_bit - only lowest-order bit used
41 * @f_bit - only lowest-order bit used
42 * @laddr - SAP value in this 'lsap'
43 * @node - entry in station sap_list
44 * @sk_list - LLC sockets this one manages
45 */
46struct llc_sap {
47 unsigned char state;
48 unsigned char p_bit;
49 unsigned char f_bit;
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030050 atomic_t refcnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 int (*rcv_func)(struct sk_buff *skb,
52 struct net_device *dev,
David S. Millerf2ccd8f2005-08-09 19:34:12 -070053 struct packet_type *pt,
54 struct net_device *orig_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 struct llc_addr laddr;
56 struct list_head node;
Octavian Purdilab76f5a82009-12-26 11:51:02 +000057 spinlock_t sk_lock;
58 struct hlist_nulls_head sk_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059};
60
61#define LLC_DEST_INVALID 0 /* Invalid LLC PDU type */
62#define LLC_DEST_SAP 1 /* Type 1 goes here */
63#define LLC_DEST_CONN 2 /* Type 2 goes here */
64
65extern struct list_head llc_sap_list;
66extern rwlock_t llc_sap_list_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68extern int llc_rcv(struct sk_buff *skb, struct net_device *dev,
David S. Millerf2ccd8f2005-08-09 19:34:12 -070069 struct packet_type *pt, struct net_device *orig_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
71extern int llc_mac_hdr_init(struct sk_buff *skb,
Stephen Hemmingerf4ad2b12006-03-20 22:59:36 -080072 const unsigned char *sa, const unsigned char *da);
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74extern void llc_add_pack(int type, void (*handler)(struct llc_sap *sap,
75 struct sk_buff *skb));
76extern void llc_remove_pack(int type);
77
78extern void llc_set_station_handler(void (*handler)(struct sk_buff *skb));
79
80extern struct llc_sap *llc_sap_open(unsigned char lsap,
81 int (*rcv)(struct sk_buff *skb,
82 struct net_device *dev,
David S. Millerf2ccd8f2005-08-09 19:34:12 -070083 struct packet_type *pt,
84 struct net_device *orig_dev));
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030085static inline void llc_sap_hold(struct llc_sap *sap)
86{
87 atomic_inc(&sap->refcnt);
88}
89
Arnaldo Carvalho de Melo2928c192005-09-22 05:14:33 -030090extern void llc_sap_close(struct llc_sap *sap);
91
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030092static inline void llc_sap_put(struct llc_sap *sap)
93{
Arnaldo Carvalho de Melo6e2144b2005-09-22 04:43:05 -030094 if (atomic_dec_and_test(&sap->refcnt))
95 llc_sap_close(sap);
96}
Linus Torvalds1da177e2005-04-16 15:20:36 -070097
98extern struct llc_sap *llc_sap_find(unsigned char sap_value);
99
100extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb,
101 unsigned char *dmac, unsigned char dsap);
102
Arnaldo Carvalho de Melo2928c192005-09-22 05:14:33 -0300103extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb);
104extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb);
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int llc_station_init(void);
107extern void llc_station_exit(void);
108
109#ifdef CONFIG_PROC_FS
110extern int llc_proc_init(void);
111extern void llc_proc_exit(void);
112#else
113#define llc_proc_init() (0)
114#define llc_proc_exit() do { } while(0)
115#endif /* CONFIG_PROC_FS */
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300116#ifdef CONFIG_SYSCTL
117extern int llc_sysctl_init(void);
118extern void llc_sysctl_exit(void);
Arnaldo Carvalho de Melo2928c192005-09-22 05:14:33 -0300119
120extern int sysctl_llc2_ack_timeout;
121extern int sysctl_llc2_busy_timeout;
122extern int sysctl_llc2_p_timeout;
123extern int sysctl_llc2_rej_timeout;
124extern int sysctl_llc_station_ack_timeout;
Arnaldo Carvalho de Melo590232a2005-09-22 04:30:44 -0300125#else
126#define llc_sysctl_init() (0)
127#define llc_sysctl_exit() do { } while(0)
128#endif /* CONFIG_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#endif /* LLC_H */