blob: e9ebac2e2ecc97d4db3e73615a9ddc020c47ba6a [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_ATALK_H__
2#define __LINUX_ATALK_H__
3
David S. Miller32e9e252005-06-26 15:28:10 -07004#include <asm/byteorder.h>
5
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
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
24struct atalk_addr {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070025 __be16 s_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070026 __u8 s_node;
27};
28
29struct 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
36struct atalk_netrange {
37 __u8 nr_phase;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070038 __be16 nr_firstnet;
39 __be16 nr_lastnet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040};
41
David S. Miller9f3786d2005-04-16 15:24:09 -070042#ifdef __KERNEL__
43
44#include <net/sock.h>
45
Linus Torvalds1da177e2005-04-16 15:20:36 -070046struct atalk_route {
47 struct net_device *dev;
48 struct atalk_addr target;
49 struct atalk_addr gateway;
50 int flags;
51 struct atalk_route *next;
52};
53
54/**
55 * struct atalk_iface - AppleTalk Interface
56 * @dev - Network device associated with this interface
57 * @address - Our address
58 * @status - What are we doing?
59 * @nets - Associated direct netrange
60 * @next - next element in the list of interfaces
61 */
62struct atalk_iface {
63 struct net_device *dev;
64 struct atalk_addr address;
65 int status;
66#define ATIF_PROBE 1 /* Probing for an address */
67#define ATIF_PROBE_FAIL 2 /* Probe collided */
68 struct atalk_netrange nets;
69 struct atalk_iface *next;
70};
71
72struct atalk_sock {
73 /* struct sock has to be the first member of atalk_sock */
74 struct sock sk;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070075 __be16 dest_net;
76 __be16 src_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 unsigned char dest_node;
78 unsigned char src_node;
79 unsigned char dest_port;
80 unsigned char src_port;
81};
82
83static inline struct atalk_sock *at_sk(struct sock *sk)
84{
85 return (struct atalk_sock *)sk;
86}
87
Linus Torvalds1da177e2005-04-16 15:20:36 -070088struct ddpehdr {
Al Viro2a50f282006-09-26 21:22:08 -070089 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070090 __be16 deh_sum;
91 __be16 deh_dnet;
92 __be16 deh_snet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 __u8 deh_dnode;
94 __u8 deh_snode;
95 __u8 deh_dport;
96 __u8 deh_sport;
97 /* And netatalk apps expect to stick the type in themselves */
98};
99
100static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
101{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -0700102 return (struct ddpehdr *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105/* AppleTalk AARP headers */
106struct elapaarp {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700107 __be16 hw_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#define AARP_HW_TYPE_ETHERNET 1
109#define AARP_HW_TYPE_TOKENRING 2
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700110 __be16 pa_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111 __u8 hw_len;
112 __u8 pa_len;
113#define AARP_PA_ALEN 4
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700114 __be16 function;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#define AARP_REQUEST 1
116#define AARP_REPLY 2
117#define AARP_PROBE 3
Jan Blunck6a878182006-01-08 01:05:07 -0800118 __u8 hw_src[ETH_ALEN];
119 __u8 pa_src_zero;
120 __be16 pa_src_net;
121 __u8 pa_src_node;
122 __u8 hw_dst[ETH_ALEN];
123 __u8 pa_dst_zero;
124 __be16 pa_dst_net;
125 __u8 pa_dst_node;
126} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
129{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -0700130 return (struct elapaarp *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131}
132
133/* Not specified - how long till we drop a resolved entry */
134#define AARP_EXPIRY_TIME (5 * 60 * HZ)
135/* Size of hash table */
136#define AARP_HASH_SIZE 16
137/* Fast retransmission timer when resolving */
138#define AARP_TICK_TIME (HZ / 5)
139/* Send 10 requests then give up (2 seconds) */
140#define AARP_RETRANSMIT_LIMIT 10
141/*
142 * Some value bigger than total retransmit time + a bit for last reply to
143 * appear and to stop continual requests
144 */
145#define AARP_RESOLVE_TIME (10 * HZ)
146
147extern struct datalink_proto *ddp_dl, *aarp_dl;
148extern void aarp_proto_init(void);
149
150/* Inter module exports */
151
152/* Give a device find its atif control structure */
153static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
154{
155 return dev->atalk_ptr;
156}
157
158extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
159extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
160extern int aarp_send_ddp(struct net_device *dev,
161 struct sk_buff *skb,
162 struct atalk_addr *sa, void *hwaddr);
163extern void aarp_device_down(struct net_device *dev);
164extern void aarp_probe_network(struct atalk_iface *atif);
165extern int aarp_proxy_probe_network(struct atalk_iface *atif,
166 struct atalk_addr *sa);
167extern void aarp_proxy_remove(struct net_device *dev,
168 struct atalk_addr *sa);
169
170extern void aarp_cleanup_module(void);
171
172extern struct hlist_head atalk_sockets;
173extern rwlock_t atalk_sockets_lock;
174
175extern struct atalk_route *atalk_routes;
176extern rwlock_t atalk_routes_lock;
177
178extern struct atalk_iface *atalk_interfaces;
179extern rwlock_t atalk_interfaces_lock;
180
181extern struct atalk_route atrtr_default;
182
Arjan van de Ven54047322007-02-12 00:55:28 -0800183extern const struct file_operations atalk_seq_arp_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185extern int sysctl_aarp_expiry_time;
186extern int sysctl_aarp_tick_time;
187extern int sysctl_aarp_retransmit_limit;
188extern int sysctl_aarp_resolve_time;
189
190#ifdef CONFIG_SYSCTL
191extern void atalk_register_sysctl(void);
192extern void atalk_unregister_sysctl(void);
193#else
194#define atalk_register_sysctl() do { } while(0)
195#define atalk_unregister_sysctl() do { } while(0)
196#endif
197
198#ifdef CONFIG_PROC_FS
199extern int atalk_proc_init(void);
200extern void atalk_proc_exit(void);
201#else
202#define atalk_proc_init() ({ 0; })
203#define atalk_proc_exit() do { } while(0)
204#endif /* CONFIG_PROC_FS */
205
206#endif /* __KERNEL__ */
207#endif /* __LINUX_ATALK_H__ */