atalk.h 5.8 KB

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