]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/linux/atalk.h
Linux-2.6.12-rc2
[mirror_ubuntu-artful-kernel.git] / include / linux / atalk.h
1 #ifndef __LINUX_ATALK_H__
2 #define __LINUX_ATALK_H__
3
4 #include <net/sock.h>
5
6 /*
7 * AppleTalk networking structures
8 *
9 * The following are directly referenced from the University Of Michigan
10 * netatalk for compatibility reasons.
11 */
12 #define ATPORT_FIRST 1
13 #define ATPORT_RESERVED 128
14 #define ATPORT_LAST 254 /* 254 is only legal on localtalk */
15 #define ATADDR_ANYNET (__u16)0
16 #define ATADDR_ANYNODE (__u8)0
17 #define ATADDR_ANYPORT (__u8)0
18 #define ATADDR_BCAST (__u8)255
19 #define DDP_MAXSZ 587
20 #define DDP_MAXHOPS 15 /* 4 bits of hop counter */
21
22 #define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
23
24 struct atalk_addr {
25 __u16 s_net;
26 __u8 s_node;
27 };
28
29 struct sockaddr_at {
30 sa_family_t sat_family;
31 __u8 sat_port;
32 struct atalk_addr sat_addr;
33 char sat_zero[8];
34 };
35
36 struct atalk_netrange {
37 __u8 nr_phase;
38 __u16 nr_firstnet;
39 __u16 nr_lastnet;
40 };
41
42 struct atalk_route {
43 struct net_device *dev;
44 struct atalk_addr target;
45 struct atalk_addr gateway;
46 int flags;
47 struct atalk_route *next;
48 };
49
50 /**
51 * struct atalk_iface - AppleTalk Interface
52 * @dev - Network device associated with this interface
53 * @address - Our address
54 * @status - What are we doing?
55 * @nets - Associated direct netrange
56 * @next - next element in the list of interfaces
57 */
58 struct atalk_iface {
59 struct net_device *dev;
60 struct atalk_addr address;
61 int status;
62 #define ATIF_PROBE 1 /* Probing for an address */
63 #define ATIF_PROBE_FAIL 2 /* Probe collided */
64 struct atalk_netrange nets;
65 struct atalk_iface *next;
66 };
67
68 struct atalk_sock {
69 /* struct sock has to be the first member of atalk_sock */
70 struct sock sk;
71 unsigned short dest_net;
72 unsigned short src_net;
73 unsigned char dest_node;
74 unsigned char src_node;
75 unsigned char dest_port;
76 unsigned char src_port;
77 };
78
79 static inline struct atalk_sock *at_sk(struct sock *sk)
80 {
81 return (struct atalk_sock *)sk;
82 }
83
84 #ifdef __KERNEL__
85
86 #include <asm/byteorder.h>
87
88 struct ddpehdr {
89 #ifdef __LITTLE_ENDIAN_BITFIELD
90 __u16 deh_len:10,
91 deh_hops:4,
92 deh_pad:2;
93 #else
94 __u16 deh_pad:2,
95 deh_hops:4,
96 deh_len:10;
97 #endif
98 __u16 deh_sum;
99 __u16 deh_dnet;
100 __u16 deh_snet;
101 __u8 deh_dnode;
102 __u8 deh_snode;
103 __u8 deh_dport;
104 __u8 deh_sport;
105 /* And netatalk apps expect to stick the type in themselves */
106 };
107
108 static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
109 {
110 return (struct ddpehdr *)skb->h.raw;
111 }
112
113 /*
114 * Don't drop the struct into the struct above. You'll get some
115 * surprise padding.
116 */
117 struct ddpebits {
118 #ifdef __LITTLE_ENDIAN_BITFIELD
119 __u16 deh_len:10,
120 deh_hops:4,
121 deh_pad:2;
122 #else
123 __u16 deh_pad:2,
124 deh_hops:4,
125 deh_len:10;
126 #endif
127 };
128
129 /* Short form header */
130 struct ddpshdr {
131 #ifdef __LITTLE_ENDIAN_BITFIELD
132 __u16 dsh_len:10,
133 dsh_pad:6;
134 #else
135 __u16 dsh_pad:6,
136 dsh_len:10;
137 #endif
138 __u8 dsh_dport;
139 __u8 dsh_sport;
140 /* And netatalk apps expect to stick the type in themselves */
141 };
142
143 /* AppleTalk AARP headers */
144 struct elapaarp {
145 __u16 hw_type;
146 #define AARP_HW_TYPE_ETHERNET 1
147 #define AARP_HW_TYPE_TOKENRING 2
148 __u16 pa_type;
149 __u8 hw_len;
150 __u8 pa_len;
151 #define AARP_PA_ALEN 4
152 __u16 function;
153 #define AARP_REQUEST 1
154 #define AARP_REPLY 2
155 #define AARP_PROBE 3
156 __u8 hw_src[ETH_ALEN] __attribute__ ((packed));
157 __u8 pa_src_zero __attribute__ ((packed));
158 __u16 pa_src_net __attribute__ ((packed));
159 __u8 pa_src_node __attribute__ ((packed));
160 __u8 hw_dst[ETH_ALEN] __attribute__ ((packed));
161 __u8 pa_dst_zero __attribute__ ((packed));
162 __u16 pa_dst_net __attribute__ ((packed));
163 __u8 pa_dst_node __attribute__ ((packed));
164 };
165
166 static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
167 {
168 return (struct elapaarp *)skb->h.raw;
169 }
170
171 /* Not specified - how long till we drop a resolved entry */
172 #define AARP_EXPIRY_TIME (5 * 60 * HZ)
173 /* Size of hash table */
174 #define AARP_HASH_SIZE 16
175 /* Fast retransmission timer when resolving */
176 #define AARP_TICK_TIME (HZ / 5)
177 /* Send 10 requests then give up (2 seconds) */
178 #define AARP_RETRANSMIT_LIMIT 10
179 /*
180 * Some value bigger than total retransmit time + a bit for last reply to
181 * appear and to stop continual requests
182 */
183 #define AARP_RESOLVE_TIME (10 * HZ)
184
185 extern struct datalink_proto *ddp_dl, *aarp_dl;
186 extern void aarp_proto_init(void);
187
188 /* Inter module exports */
189
190 /* Give a device find its atif control structure */
191 static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
192 {
193 return dev->atalk_ptr;
194 }
195
196 extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
197 extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
198 extern int aarp_send_ddp(struct net_device *dev,
199 struct sk_buff *skb,
200 struct atalk_addr *sa, void *hwaddr);
201 extern void aarp_device_down(struct net_device *dev);
202 extern void aarp_probe_network(struct atalk_iface *atif);
203 extern int aarp_proxy_probe_network(struct atalk_iface *atif,
204 struct atalk_addr *sa);
205 extern void aarp_proxy_remove(struct net_device *dev,
206 struct atalk_addr *sa);
207
208 extern void aarp_cleanup_module(void);
209
210 extern struct hlist_head atalk_sockets;
211 extern rwlock_t atalk_sockets_lock;
212
213 extern struct atalk_route *atalk_routes;
214 extern rwlock_t atalk_routes_lock;
215
216 extern struct atalk_iface *atalk_interfaces;
217 extern rwlock_t atalk_interfaces_lock;
218
219 extern struct atalk_route atrtr_default;
220
221 extern struct file_operations atalk_seq_arp_fops;
222
223 extern int sysctl_aarp_expiry_time;
224 extern int sysctl_aarp_tick_time;
225 extern int sysctl_aarp_retransmit_limit;
226 extern int sysctl_aarp_resolve_time;
227
228 #ifdef CONFIG_SYSCTL
229 extern void atalk_register_sysctl(void);
230 extern void atalk_unregister_sysctl(void);
231 #else
232 #define atalk_register_sysctl() do { } while(0)
233 #define atalk_unregister_sysctl() do { } while(0)
234 #endif
235
236 #ifdef CONFIG_PROC_FS
237 extern int atalk_proc_init(void);
238 extern void atalk_proc_exit(void);
239 #else
240 #define atalk_proc_init() ({ 0; })
241 #define atalk_proc_exit() do { } while(0)
242 #endif /* CONFIG_PROC_FS */
243
244 #endif /* __KERNEL__ */
245 #endif /* __LINUX_ATALK_H__ */