atalk.h 4.5 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
L
Linus Torvalds 已提交
2 3 4
#ifndef __LINUX_ATALK_H__
#define __LINUX_ATALK_H__

5 6

#include <net/sock.h>
7
#include <uapi/linux/atalk.h>
8

L
Linus Torvalds 已提交
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
struct atalk_route {
	struct net_device  *dev;
	struct atalk_addr  target;
	struct atalk_addr  gateway;
	int		   flags;
	struct atalk_route *next;
};

/**
 *	struct atalk_iface - AppleTalk Interface
 *	@dev - Network device associated with this interface
 *	@address - Our address
 *	@status - What are we doing?
 *	@nets - Associated direct netrange
 *	@next - next element in the list of interfaces
 */
struct atalk_iface {
	struct net_device	*dev;
	struct atalk_addr	address;
	int			status;
#define ATIF_PROBE	1		/* Probing for an address */
#define ATIF_PROBE_FAIL	2		/* Probe collided */
	struct atalk_netrange	nets;
	struct atalk_iface	*next;
};
	
struct atalk_sock {
	/* struct sock has to be the first member of atalk_sock */
	struct sock	sk;
A
Alexey Dobriyan 已提交
38 39
	__be16		dest_net;
	__be16		src_net;
L
Linus Torvalds 已提交
40 41 42 43 44 45 46 47 48 49 50 51
	unsigned char	dest_node;
	unsigned char	src_node;
	unsigned char	dest_port;
	unsigned char	src_port;
};

static inline struct atalk_sock *at_sk(struct sock *sk)
{
	return (struct atalk_sock *)sk;
}

struct ddpehdr {
A
Al Viro 已提交
52
	__be16	deh_len_hops;	/* lower 10 bits are length, next 4 - hops */
A
Alexey Dobriyan 已提交
53 54 55
	__be16	deh_sum;
	__be16	deh_dnet;
	__be16	deh_snet;
L
Linus Torvalds 已提交
56 57 58 59 60 61 62 63 64
	__u8	deh_dnode;
	__u8	deh_snode;
	__u8	deh_dport;
	__u8	deh_sport;
	/* And netatalk apps expect to stick the type in themselves */
};

static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
{
65
	return (struct ddpehdr *)skb_transport_header(skb);
L
Linus Torvalds 已提交
66 67 68 69
}

/* AppleTalk AARP headers */
struct elapaarp {
A
Alexey Dobriyan 已提交
70
	__be16	hw_type;
L
Linus Torvalds 已提交
71 72
#define AARP_HW_TYPE_ETHERNET		1
#define AARP_HW_TYPE_TOKENRING		2
A
Alexey Dobriyan 已提交
73
	__be16	pa_type;
L
Linus Torvalds 已提交
74 75 76
	__u8	hw_len;
	__u8	pa_len;
#define AARP_PA_ALEN			4
A
Alexey Dobriyan 已提交
77
	__be16	function;
L
Linus Torvalds 已提交
78 79 80
#define AARP_REQUEST			1
#define AARP_REPLY			2
#define AARP_PROBE			3
81 82 83 84 85 86 87 88 89
	__u8	hw_src[ETH_ALEN];
	__u8	pa_src_zero;
	__be16	pa_src_net;
	__u8	pa_src_node;
	__u8	hw_dst[ETH_ALEN];
	__u8	pa_dst_zero;
	__be16	pa_dst_net;
	__u8	pa_dst_node;
} __attribute__ ((packed));
L
Linus Torvalds 已提交
90 91 92

static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
{
93
	return (struct elapaarp *)skb_transport_header(skb);
L
Linus Torvalds 已提交
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
}

/* Not specified - how long till we drop a resolved entry */
#define AARP_EXPIRY_TIME	(5 * 60 * HZ)
/* Size of hash table */
#define AARP_HASH_SIZE		16
/* Fast retransmission timer when resolving */
#define AARP_TICK_TIME		(HZ / 5)
/* Send 10 requests then give up (2 seconds) */
#define AARP_RETRANSMIT_LIMIT	10
/*
 * Some value bigger than total retransmit time + a bit for last reply to
 * appear and to stop continual requests
 */
#define AARP_RESOLVE_TIME	(10 * HZ)

extern struct datalink_proto *ddp_dl, *aarp_dl;
111
extern int aarp_proto_init(void);
L
Linus Torvalds 已提交
112 113 114 115

/* Inter module exports */

/* Give a device find its atif control structure */
116
#if IS_ENABLED(CONFIG_IRDA) || IS_ENABLED(CONFIG_ATALK)
L
Linus Torvalds 已提交
117 118 119 120
static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
{
	return dev->atalk_ptr;
}
121
#endif
L
Linus Torvalds 已提交
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147

extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
extern int		 aarp_send_ddp(struct net_device *dev,
				       struct sk_buff *skb,
				       struct atalk_addr *sa, void *hwaddr);
extern void		 aarp_device_down(struct net_device *dev);
extern void		 aarp_probe_network(struct atalk_iface *atif);
extern int 		 aarp_proxy_probe_network(struct atalk_iface *atif,
				     struct atalk_addr *sa);
extern void		 aarp_proxy_remove(struct net_device *dev,
					   struct atalk_addr *sa);

extern void		aarp_cleanup_module(void);

extern struct hlist_head atalk_sockets;
extern rwlock_t atalk_sockets_lock;

extern struct atalk_route *atalk_routes;
extern rwlock_t atalk_routes_lock;

extern struct atalk_iface *atalk_interfaces;
extern rwlock_t atalk_interfaces_lock;

extern struct atalk_route atrtr_default;

148 149 150 151 152 153
struct aarp_iter_state {
	int bucket;
	struct aarp_entry **table;
};

extern const struct seq_operations aarp_seq_ops;
L
Linus Torvalds 已提交
154 155 156 157 158 159 160

extern int sysctl_aarp_expiry_time;
extern int sysctl_aarp_tick_time;
extern int sysctl_aarp_retransmit_limit;
extern int sysctl_aarp_resolve_time;

#ifdef CONFIG_SYSCTL
161
extern int atalk_register_sysctl(void);
L
Linus Torvalds 已提交
162 163
extern void atalk_unregister_sysctl(void);
#else
164 165 166 167 168 169 170
static inline int atalk_register_sysctl(void)
{
	return 0;
}
static inline void atalk_unregister_sysctl(void)
{
}
L
Linus Torvalds 已提交
171 172 173 174 175 176
#endif

#ifdef CONFIG_PROC_FS
extern int atalk_proc_init(void);
extern void atalk_proc_exit(void);
#else
177 178 179 180 181 182 183
static inline int atalk_proc_init(void)
{
	return 0;
}
static inline void atalk_proc_exit(void)
{
}
L
Linus Torvalds 已提交
184 185 186
#endif /* CONFIG_PROC_FS */

#endif /* __LINUX_ATALK_H__ */