blob: d34c187432ed883e6bcb498c6d9299c68e68d118 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_ATALK_H__
2#define __LINUX_ATALK_H__
3
Jaswinder Singh Rajput85c09562009-01-30 20:26:25 +05304#include <linux/types.h>
David S. Miller32e9e252005-06-26 15:28:10 -07005#include <asm/byteorder.h>
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007/*
8 * AppleTalk networking structures
9 *
10 * The following are directly referenced from the University Of Michigan
11 * netatalk for compatibility reasons.
12 */
13#define ATPORT_FIRST 1
14#define ATPORT_RESERVED 128
15#define ATPORT_LAST 254 /* 254 is only legal on localtalk */
16#define ATADDR_ANYNET (__u16)0
17#define ATADDR_ANYNODE (__u8)0
18#define ATADDR_ANYPORT (__u8)0
19#define ATADDR_BCAST (__u8)255
20#define DDP_MAXSZ 587
21#define DDP_MAXHOPS 15 /* 4 bits of hop counter */
22
23#define SIOCATALKDIFADDR (SIOCPROTOPRIVATE + 0)
24
25struct atalk_addr {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070026 __be16 s_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 __u8 s_node;
28};
29
30struct sockaddr_at {
31 sa_family_t sat_family;
32 __u8 sat_port;
33 struct atalk_addr sat_addr;
34 char sat_zero[8];
35};
36
37struct atalk_netrange {
38 __u8 nr_phase;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070039 __be16 nr_firstnet;
40 __be16 nr_lastnet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041};
42
David S. Miller9f3786d2005-04-16 15:24:09 -070043#ifdef __KERNEL__
44
45#include <net/sock.h>
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047struct atalk_route {
48 struct net_device *dev;
49 struct atalk_addr target;
50 struct atalk_addr gateway;
51 int flags;
52 struct atalk_route *next;
53};
54
55/**
56 * struct atalk_iface - AppleTalk Interface
57 * @dev - Network device associated with this interface
58 * @address - Our address
59 * @status - What are we doing?
60 * @nets - Associated direct netrange
61 * @next - next element in the list of interfaces
62 */
63struct atalk_iface {
64 struct net_device *dev;
65 struct atalk_addr address;
66 int status;
67#define ATIF_PROBE 1 /* Probing for an address */
68#define ATIF_PROBE_FAIL 2 /* Probe collided */
69 struct atalk_netrange nets;
70 struct atalk_iface *next;
71};
72
73struct atalk_sock {
74 /* struct sock has to be the first member of atalk_sock */
75 struct sock sk;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070076 __be16 dest_net;
77 __be16 src_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 unsigned char dest_node;
79 unsigned char src_node;
80 unsigned char dest_port;
81 unsigned char src_port;
82};
83
84static inline struct atalk_sock *at_sk(struct sock *sk)
85{
86 return (struct atalk_sock *)sk;
87}
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089struct ddpehdr {
Al Viro2a50f282006-09-26 21:22:08 -070090 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070091 __be16 deh_sum;
92 __be16 deh_dnet;
93 __be16 deh_snet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 __u8 deh_dnode;
95 __u8 deh_snode;
96 __u8 deh_dport;
97 __u8 deh_sport;
98 /* And netatalk apps expect to stick the type in themselves */
99};
100
101static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
102{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -0700103 return (struct ddpehdr *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104}
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/* AppleTalk AARP headers */
107struct elapaarp {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700108 __be16 hw_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#define AARP_HW_TYPE_ETHERNET 1
110#define AARP_HW_TYPE_TOKENRING 2
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700111 __be16 pa_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112 __u8 hw_len;
113 __u8 pa_len;
114#define AARP_PA_ALEN 4
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -0700115 __be16 function;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#define AARP_REQUEST 1
117#define AARP_REPLY 2
118#define AARP_PROBE 3
Jan Blunck6a878182006-01-08 01:05:07 -0800119 __u8 hw_src[ETH_ALEN];
120 __u8 pa_src_zero;
121 __be16 pa_src_net;
122 __u8 pa_src_node;
123 __u8 hw_dst[ETH_ALEN];
124 __u8 pa_dst_zero;
125 __be16 pa_dst_net;
126 __u8 pa_dst_node;
127} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
129static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
130{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -0700131 return (struct elapaarp *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132}
133
134/* Not specified - how long till we drop a resolved entry */
135#define AARP_EXPIRY_TIME (5 * 60 * HZ)
136/* Size of hash table */
137#define AARP_HASH_SIZE 16
138/* Fast retransmission timer when resolving */
139#define AARP_TICK_TIME (HZ / 5)
140/* Send 10 requests then give up (2 seconds) */
141#define AARP_RETRANSMIT_LIMIT 10
142/*
143 * Some value bigger than total retransmit time + a bit for last reply to
144 * appear and to stop continual requests
145 */
146#define AARP_RESOLVE_TIME (10 * HZ)
147
148extern struct datalink_proto *ddp_dl, *aarp_dl;
149extern void aarp_proto_init(void);
150
151/* Inter module exports */
152
153/* Give a device find its atif control structure */
154static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
155{
156 return dev->atalk_ptr;
157}
158
159extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
160extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
161extern int aarp_send_ddp(struct net_device *dev,
162 struct sk_buff *skb,
163 struct atalk_addr *sa, void *hwaddr);
164extern void aarp_device_down(struct net_device *dev);
165extern void aarp_probe_network(struct atalk_iface *atif);
166extern int aarp_proxy_probe_network(struct atalk_iface *atif,
167 struct atalk_addr *sa);
168extern void aarp_proxy_remove(struct net_device *dev,
169 struct atalk_addr *sa);
170
171extern void aarp_cleanup_module(void);
172
173extern struct hlist_head atalk_sockets;
174extern rwlock_t atalk_sockets_lock;
175
176extern struct atalk_route *atalk_routes;
177extern rwlock_t atalk_routes_lock;
178
179extern struct atalk_iface *atalk_interfaces;
180extern rwlock_t atalk_interfaces_lock;
181
182extern struct atalk_route atrtr_default;
183
Arjan van de Ven54047322007-02-12 00:55:28 -0800184extern const struct file_operations atalk_seq_arp_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186extern int sysctl_aarp_expiry_time;
187extern int sysctl_aarp_tick_time;
188extern int sysctl_aarp_retransmit_limit;
189extern int sysctl_aarp_resolve_time;
190
191#ifdef CONFIG_SYSCTL
192extern void atalk_register_sysctl(void);
193extern void atalk_unregister_sysctl(void);
194#else
195#define atalk_register_sysctl() do { } while(0)
196#define atalk_unregister_sysctl() do { } while(0)
197#endif
198
199#ifdef CONFIG_PROC_FS
200extern int atalk_proc_init(void);
201extern void atalk_proc_exit(void);
202#else
203#define atalk_proc_init() ({ 0; })
204#define atalk_proc_exit() do { } while(0)
205#endif /* CONFIG_PROC_FS */
206
207#endif /* __KERNEL__ */
208#endif /* __LINUX_ATALK_H__ */