blob: 73fd8b7e9534434d663aa2a18ab5c2a58421b739 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __LINUX_ATALK_H__
2#define __LINUX_ATALK_H__
3
David S. Miller9f3786d2005-04-16 15:24:09 -07004
5#include <net/sock.h>
David Howells607ca462012-10-13 10:46:48 +01006#include <uapi/linux/atalk.h>
David S. Miller9f3786d2005-04-16 15:24:09 -07007
Linus Torvalds1da177e2005-04-16 15:20:36 -07008struct atalk_route {
9 struct net_device *dev;
10 struct atalk_addr target;
11 struct atalk_addr gateway;
12 int flags;
13 struct atalk_route *next;
14};
15
16/**
17 * struct atalk_iface - AppleTalk Interface
18 * @dev - Network device associated with this interface
19 * @address - Our address
20 * @status - What are we doing?
21 * @nets - Associated direct netrange
22 * @next - next element in the list of interfaces
23 */
24struct atalk_iface {
25 struct net_device *dev;
26 struct atalk_addr address;
27 int status;
28#define ATIF_PROBE 1 /* Probing for an address */
29#define ATIF_PROBE_FAIL 2 /* Probe collided */
30 struct atalk_netrange nets;
31 struct atalk_iface *next;
32};
33
34struct atalk_sock {
35 /* struct sock has to be the first member of atalk_sock */
36 struct sock sk;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070037 __be16 dest_net;
38 __be16 src_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 unsigned char dest_node;
40 unsigned char src_node;
41 unsigned char dest_port;
42 unsigned char src_port;
43};
44
45static inline struct atalk_sock *at_sk(struct sock *sk)
46{
47 return (struct atalk_sock *)sk;
48}
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050struct ddpehdr {
Al Viro2a50f282006-09-26 21:22:08 -070051 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070052 __be16 deh_sum;
53 __be16 deh_dnet;
54 __be16 deh_snet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 __u8 deh_dnode;
56 __u8 deh_snode;
57 __u8 deh_dport;
58 __u8 deh_sport;
59 /* And netatalk apps expect to stick the type in themselves */
60};
61
62static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
63{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070064 return (struct ddpehdr *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070065}
66
Linus Torvalds1da177e2005-04-16 15:20:36 -070067/* AppleTalk AARP headers */
68struct elapaarp {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070069 __be16 hw_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070#define AARP_HW_TYPE_ETHERNET 1
71#define AARP_HW_TYPE_TOKENRING 2
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070072 __be16 pa_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 __u8 hw_len;
74 __u8 pa_len;
75#define AARP_PA_ALEN 4
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070076 __be16 function;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define AARP_REQUEST 1
78#define AARP_REPLY 2
79#define AARP_PROBE 3
Jan Blunck6a878182006-01-08 01:05:07 -080080 __u8 hw_src[ETH_ALEN];
81 __u8 pa_src_zero;
82 __be16 pa_src_net;
83 __u8 pa_src_node;
84 __u8 hw_dst[ETH_ALEN];
85 __u8 pa_dst_zero;
86 __be16 pa_dst_net;
87 __u8 pa_dst_node;
88} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
91{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070092 return (struct elapaarp *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
95/* Not specified - how long till we drop a resolved entry */
96#define AARP_EXPIRY_TIME (5 * 60 * HZ)
97/* Size of hash table */
98#define AARP_HASH_SIZE 16
99/* Fast retransmission timer when resolving */
100#define AARP_TICK_TIME (HZ / 5)
101/* Send 10 requests then give up (2 seconds) */
102#define AARP_RETRANSMIT_LIMIT 10
103/*
104 * Some value bigger than total retransmit time + a bit for last reply to
105 * appear and to stop continual requests
106 */
107#define AARP_RESOLVE_TIME (10 * HZ)
108
109extern struct datalink_proto *ddp_dl, *aarp_dl;
110extern void aarp_proto_init(void);
111
112/* Inter module exports */
113
114/* Give a device find its atif control structure */
115static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
116{
117 return dev->atalk_ptr;
118}
119
120extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
121extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
122extern int aarp_send_ddp(struct net_device *dev,
123 struct sk_buff *skb,
124 struct atalk_addr *sa, void *hwaddr);
125extern void aarp_device_down(struct net_device *dev);
126extern void aarp_probe_network(struct atalk_iface *atif);
127extern int aarp_proxy_probe_network(struct atalk_iface *atif,
128 struct atalk_addr *sa);
129extern void aarp_proxy_remove(struct net_device *dev,
130 struct atalk_addr *sa);
131
132extern void aarp_cleanup_module(void);
133
134extern struct hlist_head atalk_sockets;
135extern rwlock_t atalk_sockets_lock;
136
137extern struct atalk_route *atalk_routes;
138extern rwlock_t atalk_routes_lock;
139
140extern struct atalk_iface *atalk_interfaces;
141extern rwlock_t atalk_interfaces_lock;
142
143extern struct atalk_route atrtr_default;
144
Arjan van de Ven54047322007-02-12 00:55:28 -0800145extern const struct file_operations atalk_seq_arp_fops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
147extern int sysctl_aarp_expiry_time;
148extern int sysctl_aarp_tick_time;
149extern int sysctl_aarp_retransmit_limit;
150extern int sysctl_aarp_resolve_time;
151
152#ifdef CONFIG_SYSCTL
153extern void atalk_register_sysctl(void);
154extern void atalk_unregister_sysctl(void);
155#else
156#define atalk_register_sysctl() do { } while(0)
157#define atalk_unregister_sysctl() do { } while(0)
158#endif
159
160#ifdef CONFIG_PROC_FS
161extern int atalk_proc_init(void);
162extern void atalk_proc_exit(void);
163#else
164#define atalk_proc_init() ({ 0; })
165#define atalk_proc_exit() do { } while(0)
166#endif /* CONFIG_PROC_FS */
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168#endif /* __LINUX_ATALK_H__ */