1#ifndef __LINUX_ATALK_H__
2#define __LINUX_ATALK_H__
3
4
5#include <net/sock.h>
6#include <uapi/linux/atalk.h>
7
8struct atalk_route {
9	struct net_device  *dev;
10	struct atalk_addr  target;
11	struct atalk_addr  gateway;
12	int		   flags;
13	struct atalk_route *next;
14};
15
16/**
17 *	struct atalk_iface - AppleTalk Interface
18 *	@dev - Network device associated with this interface
19 *	@address - Our address
20 *	@status - What are we doing?
21 *	@nets - Associated direct netrange
22 *	@next - next element in the list of interfaces
23 */
24struct atalk_iface {
25	struct net_device	*dev;
26	struct atalk_addr	address;
27	int			status;
28#define ATIF_PROBE	1		/* Probing for an address */
29#define ATIF_PROBE_FAIL	2		/* Probe collided */
30	struct atalk_netrange	nets;
31	struct atalk_iface	*next;
32};
33
34struct atalk_sock {
35	/* struct sock has to be the first member of atalk_sock */
36	struct sock	sk;
37	__be16		dest_net;
38	__be16		src_net;
39	unsigned char	dest_node;
40	unsigned char	src_node;
41	unsigned char	dest_port;
42	unsigned char	src_port;
43};
44
45static inline struct atalk_sock *at_sk(struct sock *sk)
46{
47	return (struct atalk_sock *)sk;
48}
49
50struct ddpehdr {
51	__be16	deh_len_hops;	/* lower 10 bits are length, next 4 - hops */
52	__be16	deh_sum;
53	__be16	deh_dnet;
54	__be16	deh_snet;
55	__u8	deh_dnode;
56	__u8	deh_snode;
57	__u8	deh_dport;
58	__u8	deh_sport;
59	/* And netatalk apps expect to stick the type in themselves */
60};
61
62static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
63{
64	return (struct ddpehdr *)skb_transport_header(skb);
65}
66
67/* AppleTalk AARP headers */
68struct elapaarp {
69	__be16	hw_type;
70#define AARP_HW_TYPE_ETHERNET		1
71#define AARP_HW_TYPE_TOKENRING		2
72	__be16	pa_type;
73	__u8	hw_len;
74	__u8	pa_len;
75#define AARP_PA_ALEN			4
76	__be16	function;
77#define AARP_REQUEST			1
78#define AARP_REPLY			2
79#define AARP_PROBE			3
80	__u8	hw_src[ETH_ALEN];
81	__u8	pa_src_zero;
82	__be16	pa_src_net;
83	__u8	pa_src_node;
84	__u8	hw_dst[ETH_ALEN];
85	__u8	pa_dst_zero;
86	__be16	pa_dst_net;
87	__u8	pa_dst_node;
88} __attribute__ ((packed));
89
90static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
91{
92	return (struct elapaarp *)skb_transport_header(skb);
93}
94
95/* Not specified - how long till we drop a resolved entry */
96#define AARP_EXPIRY_TIME	(5 * 60 * HZ)
97/* Size of hash table */
98#define AARP_HASH_SIZE		16
99/* Fast retransmission timer when resolving */
100#define AARP_TICK_TIME		(HZ / 5)
101/* Send 10 requests then give up (2 seconds) */
102#define AARP_RETRANSMIT_LIMIT	10
103/*
104 * Some value bigger than total retransmit time + a bit for last reply to
105 * appear and to stop continual requests
106 */
107#define AARP_RESOLVE_TIME	(10 * HZ)
108
109extern struct datalink_proto *ddp_dl, *aarp_dl;
110extern void aarp_proto_init(void);
111
112/* Inter module exports */
113
114/* Give a device find its atif control structure */
115static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
116{
117	return dev->atalk_ptr;
118}
119
120extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
121extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
122extern int		 aarp_send_ddp(struct net_device *dev,
123				       struct sk_buff *skb,
124				       struct atalk_addr *sa, void *hwaddr);
125extern void		 aarp_device_down(struct net_device *dev);
126extern void		 aarp_probe_network(struct atalk_iface *atif);
127extern int 		 aarp_proxy_probe_network(struct atalk_iface *atif,
128				     struct atalk_addr *sa);
129extern void		 aarp_proxy_remove(struct net_device *dev,
130					   struct atalk_addr *sa);
131
132extern void		aarp_cleanup_module(void);
133
134extern struct hlist_head atalk_sockets;
135extern rwlock_t atalk_sockets_lock;
136
137extern struct atalk_route *atalk_routes;
138extern rwlock_t atalk_routes_lock;
139
140extern struct atalk_iface *atalk_interfaces;
141extern rwlock_t atalk_interfaces_lock;
142
143extern struct atalk_route atrtr_default;
144
145extern const struct file_operations atalk_seq_arp_fops;
146
147extern int sysctl_aarp_expiry_time;
148extern int sysctl_aarp_tick_time;
149extern int sysctl_aarp_retransmit_limit;
150extern int sysctl_aarp_resolve_time;
151
152#ifdef CONFIG_SYSCTL
153extern void atalk_register_sysctl(void);
154extern void atalk_unregister_sysctl(void);
155#else
156#define atalk_register_sysctl()		do { } while(0)
157#define atalk_unregister_sysctl()	do { } while(0)
158#endif
159
160#ifdef CONFIG_PROC_FS
161extern int atalk_proc_init(void);
162extern void atalk_proc_exit(void);
163#else
164#define atalk_proc_init()	({ 0; })
165#define atalk_proc_exit()	do { } while(0)
166#endif /* CONFIG_PROC_FS */
167
168#endif /* __LINUX_ATALK_H__ */
169