atalk.h 5.8 KB

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