1 /*
2  *	AppleTalk networking structures
3  *
4  *	The following are directly referenced from the University Of Michigan
5  *	netatalk for compatibility reasons.
6  */
7 
8 #ifndef __LINUX_ATALK_H__
9 #define __LINUX_ATALK_H__
10 
11 #define ATPORT_FIRST	1
12 #define ATPORT_RESERVED	128
13 #define ATPORT_LAST	254 /* 254 is only legal on localtalk */
14 #define ATADDR_ANYNET	(__u16)0
15 #define ATADDR_ANYNODE	(__u8)0
16 #define ATADDR_ANYPORT  (__u8)0
17 #define ATADDR_BCAST	(__u8)255
18 #define DDP_MAXSZ	587
19 #define DDP_MAXHOPS     15      /* 4 bits of hop counter */
20 
21 #define SIOCATALKDIFADDR       (SIOCPROTOPRIVATE + 0)
22 
23 struct at_addr
24 {
25 	__u16	s_net;
26 	__u8	s_node;
27 };
28 
29 struct sockaddr_at
30 {
31 	sa_family_t	sat_family;
32 	__u8		sat_port;
33 	struct at_addr	sat_addr;
34 	char		sat_zero[ 8 ];
35 };
36 
37 struct netrange
38 {
39 	__u8	nr_phase;
40 	__u16	nr_firstnet;
41 	__u16	nr_lastnet;
42 };
43 
44 struct atalk_route
45 {
46 	struct net_device *dev;
47 	struct at_addr target;
48 	struct at_addr gateway;
49 	int flags;
50 	struct atalk_route *next;
51 };
52 
53 struct atalk_iface
54 {
55 	struct net_device *dev;
56 	struct at_addr address;		/* Our address */
57 	int status;			/* What are we doing? */
58 #define ATIF_PROBE	1		/* Probing for an address */
59 #define ATIF_PROBE_FAIL	2		/* Probe collided */
60 	struct netrange nets;		/* Associated direct netrange */
61 	struct atalk_iface *next;
62 };
63 
64 struct atalk_sock
65 {
66 	unsigned short dest_net;
67 	unsigned short src_net;
68 	unsigned char dest_node;
69 	unsigned char src_node;
70 	unsigned char dest_port;
71 	unsigned char src_port;
72 };
73 
74 #ifdef __KERNEL__
75 
76 #include <asm/byteorder.h>
77 
78 struct ddpehdr
79 {
80 #ifdef __LITTLE_ENDIAN_BITFIELD
81 	__u16	deh_len:10, deh_hops:4, deh_pad:2;
82 #else
83 	__u16	deh_pad:2, deh_hops:4, deh_len:10;
84 #endif
85 	__u16	deh_sum;
86 	__u16	deh_dnet;
87 	__u16	deh_snet;
88 	__u8	deh_dnode;
89 	__u8	deh_snode;
90 	__u8	deh_dport;
91 	__u8	deh_sport;
92 	/* And netatalk apps expect to stick the type in themselves */
93 };
94 
95 /*
96  *	Don't drop the struct into the struct above.  You'll get some
97  *	surprise padding.
98  */
99 
100 struct ddpebits
101 {
102 #ifdef __LITTLE_ENDIAN_BITFIELD
103 	__u16	deh_len:10, deh_hops:4, deh_pad:2;
104 #else
105 	__u16	deh_pad:2, deh_hops:4, deh_len:10;
106 #endif
107 };
108 
109 /*
110  *	Short form header
111  */
112 
113 struct ddpshdr
114 {
115 #ifdef __LITTLE_ENDIAN_BITFIELD
116 	__u16	dsh_len:10, dsh_pad:6;
117 #else
118 	__u16	dsh_pad:6, dsh_len:10;
119 #endif
120 	__u8	dsh_dport;
121 	__u8	dsh_sport;
122 	/* And netatalk apps expect to stick the type in themselves */
123 };
124 
125 /* AppleTalk AARP headers */
126 
127 struct elapaarp
128 {
129 	__u16	hw_type;
130 #define AARP_HW_TYPE_ETHERNET		1
131 #define AARP_HW_TYPE_TOKENRING		2
132 	__u16	pa_type;
133 	__u8	hw_len;
134 	__u8	pa_len;
135 #define AARP_PA_ALEN			4
136 	__u16	function;
137 #define AARP_REQUEST			1
138 #define AARP_REPLY			2
139 #define AARP_PROBE			3
140 	__u8	hw_src[ETH_ALEN];
141 	__u8	pa_src_zero;
142 	__u16	pa_src_net		__attribute__ ((packed));
143 	__u8	pa_src_node;
144 	__u8	hw_dst[ETH_ALEN];
145 	__u8	pa_dst_zero;
146 	__u16	pa_dst_net		__attribute__ ((packed));
147 	__u8	pa_dst_node;
148 };
149 
150 #define AARP_EXPIRY_TIME	(5*60*HZ)	/* Not specified - how long till we drop a resolved entry */
151 #define AARP_HASH_SIZE		16		/* Size of hash table */
152 #define AARP_TICK_TIME		(HZ/5)		/* Fast retransmission timer when resolving */
153 #define AARP_RETRANSMIT_LIMIT	10		/* Send 10 requests then give up (2 seconds) */
154 #define AARP_RESOLVE_TIME	(10*HZ)		/* Some value bigger than total retransmit time + a bit for last reply to appear and to stop continual requests */
155 
156 extern struct datalink_proto *ddp_dl, *aarp_dl;
157 extern void aarp_proto_init(void);
158 /* Inter module exports */
159 
160 /*
161  *	Give a device find its atif control structure
162  */
163 
atalk_find_dev(struct net_device * dev)164 static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
165 {
166 	return dev->atalk_ptr;
167 }
168 
169 extern struct at_addr *atalk_find_dev_addr(struct net_device *dev);
170 extern struct net_device *atrtr_get_dev(struct at_addr *sa);
171 extern int aarp_send_ddp(struct net_device *dev,struct sk_buff *skb, struct at_addr *sa, void *hwaddr);
172 extern void aarp_send_probe(struct net_device *dev, struct at_addr *addr);
173 extern void aarp_device_down(struct net_device *dev);
174 
175 #ifdef MODULE
176 extern void aarp_cleanup_module(void);
177 #endif /* MODULE */
178 
179 #endif /* __KERNEL__ */
180 #endif /* __LINUX_ATALK_H__ */
181