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