atalk.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. #ifndef __LINUX_ATALK_H__
  2. #define __LINUX_ATALK_H__
  3. #include <net/sock.h>
  4. #include <uapi/linux/atalk.h>
  5. struct atalk_route {
  6. struct net_device *dev;
  7. struct atalk_addr target;
  8. struct atalk_addr gateway;
  9. int flags;
  10. struct atalk_route *next;
  11. };
  12. /**
  13. * struct atalk_iface - AppleTalk Interface
  14. * @dev - Network device associated with this interface
  15. * @address - Our address
  16. * @status - What are we doing?
  17. * @nets - Associated direct netrange
  18. * @next - next element in the list of interfaces
  19. */
  20. struct atalk_iface {
  21. struct net_device *dev;
  22. struct atalk_addr address;
  23. int status;
  24. #define ATIF_PROBE 1 /* Probing for an address */
  25. #define ATIF_PROBE_FAIL 2 /* Probe collided */
  26. struct atalk_netrange nets;
  27. struct atalk_iface *next;
  28. };
  29. struct atalk_sock {
  30. /* struct sock has to be the first member of atalk_sock */
  31. struct sock sk;
  32. __be16 dest_net;
  33. __be16 src_net;
  34. unsigned char dest_node;
  35. unsigned char src_node;
  36. unsigned char dest_port;
  37. unsigned char src_port;
  38. };
  39. static inline struct atalk_sock *at_sk(struct sock *sk)
  40. {
  41. return (struct atalk_sock *)sk;
  42. }
  43. struct ddpehdr {
  44. __be16 deh_len_hops; /* lower 10 bits are length, next 4 - hops */
  45. __be16 deh_sum;
  46. __be16 deh_dnet;
  47. __be16 deh_snet;
  48. __u8 deh_dnode;
  49. __u8 deh_snode;
  50. __u8 deh_dport;
  51. __u8 deh_sport;
  52. /* And netatalk apps expect to stick the type in themselves */
  53. };
  54. static __inline__ struct ddpehdr *ddp_hdr(struct sk_buff *skb)
  55. {
  56. return (struct ddpehdr *)skb_transport_header(skb);
  57. }
  58. /* AppleTalk AARP headers */
  59. struct elapaarp {
  60. __be16 hw_type;
  61. #define AARP_HW_TYPE_ETHERNET 1
  62. #define AARP_HW_TYPE_TOKENRING 2
  63. __be16 pa_type;
  64. __u8 hw_len;
  65. __u8 pa_len;
  66. #define AARP_PA_ALEN 4
  67. __be16 function;
  68. #define AARP_REQUEST 1
  69. #define AARP_REPLY 2
  70. #define AARP_PROBE 3
  71. __u8 hw_src[ETH_ALEN];
  72. __u8 pa_src_zero;
  73. __be16 pa_src_net;
  74. __u8 pa_src_node;
  75. __u8 hw_dst[ETH_ALEN];
  76. __u8 pa_dst_zero;
  77. __be16 pa_dst_net;
  78. __u8 pa_dst_node;
  79. } __attribute__ ((packed));
  80. static __inline__ struct elapaarp *aarp_hdr(struct sk_buff *skb)
  81. {
  82. return (struct elapaarp *)skb_transport_header(skb);
  83. }
  84. /* Not specified - how long till we drop a resolved entry */
  85. #define AARP_EXPIRY_TIME (5 * 60 * HZ)
  86. /* Size of hash table */
  87. #define AARP_HASH_SIZE 16
  88. /* Fast retransmission timer when resolving */
  89. #define AARP_TICK_TIME (HZ / 5)
  90. /* Send 10 requests then give up (2 seconds) */
  91. #define AARP_RETRANSMIT_LIMIT 10
  92. /*
  93. * Some value bigger than total retransmit time + a bit for last reply to
  94. * appear and to stop continual requests
  95. */
  96. #define AARP_RESOLVE_TIME (10 * HZ)
  97. extern struct datalink_proto *ddp_dl, *aarp_dl;
  98. extern void aarp_proto_init(void);
  99. /* Inter module exports */
  100. /* Give a device find its atif control structure */
  101. static inline struct atalk_iface *atalk_find_dev(struct net_device *dev)
  102. {
  103. return dev->atalk_ptr;
  104. }
  105. extern struct atalk_addr *atalk_find_dev_addr(struct net_device *dev);
  106. extern struct net_device *atrtr_get_dev(struct atalk_addr *sa);
  107. extern int aarp_send_ddp(struct net_device *dev,
  108. struct sk_buff *skb,
  109. struct atalk_addr *sa, void *hwaddr);
  110. extern void aarp_device_down(struct net_device *dev);
  111. extern void aarp_probe_network(struct atalk_iface *atif);
  112. extern int aarp_proxy_probe_network(struct atalk_iface *atif,
  113. struct atalk_addr *sa);
  114. extern void aarp_proxy_remove(struct net_device *dev,
  115. struct atalk_addr *sa);
  116. extern void aarp_cleanup_module(void);
  117. extern struct hlist_head atalk_sockets;
  118. extern rwlock_t atalk_sockets_lock;
  119. extern struct atalk_route *atalk_routes;
  120. extern rwlock_t atalk_routes_lock;
  121. extern struct atalk_iface *atalk_interfaces;
  122. extern rwlock_t atalk_interfaces_lock;
  123. extern struct atalk_route atrtr_default;
  124. extern const struct file_operations atalk_seq_arp_fops;
  125. extern int sysctl_aarp_expiry_time;
  126. extern int sysctl_aarp_tick_time;
  127. extern int sysctl_aarp_retransmit_limit;
  128. extern int sysctl_aarp_resolve_time;
  129. #ifdef CONFIG_SYSCTL
  130. extern void atalk_register_sysctl(void);
  131. extern void atalk_unregister_sysctl(void);
  132. #else
  133. #define atalk_register_sysctl() do { } while(0)
  134. #define atalk_unregister_sysctl() do { } while(0)
  135. #endif
  136. #ifdef CONFIG_PROC_FS
  137. extern int atalk_proc_init(void);
  138. extern void atalk_proc_exit(void);
  139. #else
  140. #define atalk_proc_init() ({ 0; })
  141. #define atalk_proc_exit() do { } while(0)
  142. #endif /* CONFIG_PROC_FS */
  143. #endif /* __LINUX_ATALK_H__ */