blob: f6034ba774be313a86f006ee2e0fbe96403de6f6 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#ifndef __LINUX_ATALK_H__
3#define __LINUX_ATALK_H__
4
David S. Miller9f3786d2005-04-16 15:24:09 -07005
6#include <net/sock.h>
David Howells607ca462012-10-13 10:46:48 +01007#include <uapi/linux/atalk.h>
David S. Miller9f3786d2005-04-16 15:24:09 -07008
Linus Torvalds1da177e2005-04-16 15:20:36 -07009struct atalk_route {
10 struct net_device *dev;
11 struct atalk_addr target;
12 struct atalk_addr gateway;
13 int flags;
14 struct atalk_route *next;
15};
16
17/**
18 * struct atalk_iface - AppleTalk Interface
19 * @dev - Network device associated with this interface
20 * @address - Our address
21 * @status - What are we doing?
22 * @nets - Associated direct netrange
23 * @next - next element in the list of interfaces
24 */
25struct atalk_iface {
26 struct net_device *dev;
27 struct atalk_addr address;
28 int status;
29#define ATIF_PROBE 1 /* Probing for an address */
30#define ATIF_PROBE_FAIL 2 /* Probe collided */
31 struct atalk_netrange nets;
32 struct atalk_iface *next;
33};
34
35struct atalk_sock {
36 /* struct sock has to be the first member of atalk_sock */
37 struct sock sk;
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070038 __be16 dest_net;
39 __be16 src_net;
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 unsigned char dest_node;
41 unsigned char src_node;
42 unsigned char dest_port;
43 unsigned char src_port;
44};
45
46static inline struct atalk_sock *at_sk(struct sock *sk)
47{
48 return (struct atalk_sock *)sk;
49}
50
Linus Torvalds1da177e2005-04-16 15:20:36 -070051struct ddpehdr {
Al Viro2a50f282006-09-26 21:22:08 -070052 __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070053 __be16 deh_sum;
54 __be16 deh_dnet;
55 __be16 deh_snet;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056 __u8 deh_dnode;
57 __u8 deh_snode;
58 __u8 deh_dport;
59 __u8 deh_sport;
60 /* And netatalk apps expect to stick the type in themselves */
61};
62
63static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
64{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070065 return (struct ddpehdr *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066}
67
Linus Torvalds1da177e2005-04-16 15:20:36 -070068/* AppleTalk AARP headers */
69struct elapaarp {
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070070 __be16 hw_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#define AARP_HW_TYPE_ETHERNET 1
72#define AARP_HW_TYPE_TOKENRING 2
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070073 __be16 pa_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 __u8 hw_len;
75 __u8 pa_len;
76#define AARP_PA_ALEN 4
Alexey Dobriyanf6e276ee2005-06-20 13:32:05 -070077 __be16 function;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define AARP_REQUEST 1
79#define AARP_REPLY 2
80#define AARP_PROBE 3
Jan Blunck6a878182006-01-08 01:05:07 -080081 __u8 hw_src[ETH_ALEN];
82 __u8 pa_src_zero;
83 __be16 pa_src_net;
84 __u8 pa_src_node;
85 __u8 hw_dst[ETH_ALEN];
86 __u8 pa_dst_zero;
87 __be16 pa_dst_net;
88 __u8 pa_dst_node;
89} __attribute__ ((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
92{
Arnaldo Carvalho de Melo9c702202007-04-25 18:04:18 -070093 return (struct elapaarp *)skb_transport_header(skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
96/* Not specified - how long till we drop a resolved entry */
97#define AARP_EXPIRY_TIME (5 * 60 * HZ)
98/* Size of hash table */
99#define AARP_HASH_SIZE 16
100/* Fast retransmission timer when resolving */
101#define AARP_TICK_TIME (HZ / 5)
102/* Send 10 requests then give up (2 seconds) */
103#define AARP_RETRANSMIT_LIMIT 10
104/*
105 * Some value bigger than total retransmit time + a bit for last reply to
106 * appear and to stop continual requests
107 */
108#define AARP_RESOLVE_TIME (10 * HZ)
109
110extern struct datalink_proto *ddp_dl, *aarp_dl;
YueHaibing98045012019-03-14 13:47:59 +0800111extern int aarp_proto_init(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/* Inter module exports */
114
115/* Give a device find its atif control structure */
David Ahern89e58142018-02-13 08:52:02 -0800116#if IS_ENABLED(CONFIG_IRDA) || IS_ENABLED(CONFIG_ATALK)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
118{
119 return dev->atalk_ptr;
120}
David Ahern89e58142018-02-13 08:52:02 -0800121#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
124extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
125extern int aarp_send_ddp(struct net_device *dev,
126 struct sk_buff *skb,
127 struct atalk_addr *sa, void *hwaddr);
128extern void aarp_device_down(struct net_device *dev);
129extern void aarp_probe_network(struct atalk_iface *atif);
130extern int aarp_proxy_probe_network(struct atalk_iface *atif,
131 struct atalk_addr *sa);
132extern void aarp_proxy_remove(struct net_device *dev,
133 struct atalk_addr *sa);
134
135extern void aarp_cleanup_module(void);
136
137extern struct hlist_head atalk_sockets;
138extern rwlock_t atalk_sockets_lock;
139
140extern struct atalk_route *atalk_routes;
141extern rwlock_t atalk_routes_lock;
142
143extern struct atalk_iface *atalk_interfaces;
144extern rwlock_t atalk_interfaces_lock;
145
146extern struct atalk_route atrtr_default;
147
Christoph Hellwig44414d82018-04-24 17:05:17 +0200148struct aarp_iter_state {
149 int bucket;
150 struct aarp_entry **table;
151};
152
153extern const struct seq_operations aarp_seq_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
155extern int sysctl_aarp_expiry_time;
156extern int sysctl_aarp_tick_time;
157extern int sysctl_aarp_retransmit_limit;
158extern int sysctl_aarp_resolve_time;
159
160#ifdef CONFIG_SYSCTL
YueHaibing6377f782019-03-01 10:57:57 +0800161extern int atalk_register_sysctl(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162extern void atalk_unregister_sysctl(void);
163#else
Arnd Bergmann27da0d22019-03-06 11:52:36 +0100164static inline int atalk_register_sysctl(void)
165{
166 return 0;
167}
168static inline void atalk_unregister_sysctl(void)
169{
170}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171#endif
172
173#ifdef CONFIG_PROC_FS
174extern int atalk_proc_init(void);
175extern void atalk_proc_exit(void);
176#else
Arnd Bergmann27da0d22019-03-06 11:52:36 +0100177static inline int atalk_proc_init(void)
178{
179 return 0;
180}
181static inline void atalk_proc_exit(void)
182{
183}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184#endif /* CONFIG_PROC_FS */
185
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186#endif /* __LINUX_ATALK_H__ */