dn_dev.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. #ifndef _NET_DN_DEV_H
  2. #define _NET_DN_DEV_H
  3. struct dn_dev;
  4. struct dn_ifaddr {
  5. struct dn_ifaddr __rcu *ifa_next;
  6. struct dn_dev *ifa_dev;
  7. __le16 ifa_local;
  8. __le16 ifa_address;
  9. __u8 ifa_flags;
  10. __u8 ifa_scope;
  11. char ifa_label[IFNAMSIZ];
  12. struct rcu_head rcu;
  13. };
  14. #define DN_DEV_S_RU 0 /* Run - working normally */
  15. #define DN_DEV_S_CR 1 /* Circuit Rejected */
  16. #define DN_DEV_S_DS 2 /* Data Link Start */
  17. #define DN_DEV_S_RI 3 /* Routing Layer Initialize */
  18. #define DN_DEV_S_RV 4 /* Routing Layer Verify */
  19. #define DN_DEV_S_RC 5 /* Routing Layer Complete */
  20. #define DN_DEV_S_OF 6 /* Off */
  21. #define DN_DEV_S_HA 7 /* Halt */
  22. /*
  23. * The dn_dev_parms structure contains the set of parameters
  24. * for each device (hence inclusion in the dn_dev structure)
  25. * and an array is used to store the default types of supported
  26. * device (in dn_dev.c).
  27. *
  28. * The type field matches the ARPHRD_ constants and is used in
  29. * searching the list for supported devices when new devices
  30. * come up.
  31. *
  32. * The mode field is used to find out if a device is broadcast,
  33. * multipoint, or pointopoint. Please note that DECnet thinks
  34. * different ways about devices to the rest of the kernel
  35. * so the normal IFF_xxx flags are invalid here. For devices
  36. * which can be any combination of the previously mentioned
  37. * attributes, you can set this on a per device basis by
  38. * installing an up() routine.
  39. *
  40. * The device state field, defines the initial state in which the
  41. * device will come up. In the dn_dev structure, it is the actual
  42. * state.
  43. *
  44. * Things have changed here. I've killed timer1 since it's a user space
  45. * issue for a user space routing deamon to sort out. The kernel does
  46. * not need to be bothered with it.
  47. *
  48. * Timers:
  49. * t2 - Rate limit timer, min time between routing and hello messages
  50. * t3 - Hello timer, send hello messages when it expires
  51. *
  52. * Callbacks:
  53. * up() - Called to initialize device, return value can veto use of
  54. * device with DECnet.
  55. * down() - Called to turn device off when it goes down
  56. * timer3() - Called once for each ifaddr when timer 3 goes off
  57. *
  58. * sysctl - Hook for sysctl things
  59. *
  60. */
  61. struct dn_dev_parms {
  62. int type; /* ARPHRD_xxx */
  63. int mode; /* Broadcast, Unicast, Mulitpoint */
  64. #define DN_DEV_BCAST 1
  65. #define DN_DEV_UCAST 2
  66. #define DN_DEV_MPOINT 4
  67. int state; /* Initial state */
  68. int forwarding; /* 0=EndNode, 1=L1Router, 2=L2Router */
  69. unsigned long t2; /* Default value of t2 */
  70. unsigned long t3; /* Default value of t3 */
  71. int priority; /* Priority to be a router */
  72. char *name; /* Name for sysctl */
  73. int (*up)(struct net_device *);
  74. void (*down)(struct net_device *);
  75. void (*timer3)(struct net_device *, struct dn_ifaddr *ifa);
  76. void *sysctl;
  77. };
  78. struct dn_dev {
  79. struct dn_ifaddr __rcu *ifa_list;
  80. struct net_device *dev;
  81. struct dn_dev_parms parms;
  82. char use_long;
  83. struct timer_list timer;
  84. unsigned long t3;
  85. struct neigh_parms *neigh_parms;
  86. __u8 addr[ETH_ALEN];
  87. struct neighbour *router; /* Default router on circuit */
  88. struct neighbour *peer; /* Peer on pointopoint links */
  89. unsigned long uptime; /* Time device went up in jiffies */
  90. };
  91. struct dn_short_packet {
  92. __u8 msgflg;
  93. __le16 dstnode;
  94. __le16 srcnode;
  95. __u8 forward;
  96. } __packed;
  97. struct dn_long_packet {
  98. __u8 msgflg;
  99. __u8 d_area;
  100. __u8 d_subarea;
  101. __u8 d_id[6];
  102. __u8 s_area;
  103. __u8 s_subarea;
  104. __u8 s_id[6];
  105. __u8 nl2;
  106. __u8 visit_ct;
  107. __u8 s_class;
  108. __u8 pt;
  109. } __packed;
  110. /*------------------------- DRP - Routing messages ---------------------*/
  111. struct endnode_hello_message {
  112. __u8 msgflg;
  113. __u8 tiver[3];
  114. __u8 id[6];
  115. __u8 iinfo;
  116. __le16 blksize;
  117. __u8 area;
  118. __u8 seed[8];
  119. __u8 neighbor[6];
  120. __le16 timer;
  121. __u8 mpd;
  122. __u8 datalen;
  123. __u8 data[2];
  124. } __packed;
  125. struct rtnode_hello_message {
  126. __u8 msgflg;
  127. __u8 tiver[3];
  128. __u8 id[6];
  129. __u8 iinfo;
  130. __le16 blksize;
  131. __u8 priority;
  132. __u8 area;
  133. __le16 timer;
  134. __u8 mpd;
  135. } __packed;
  136. extern void dn_dev_init(void);
  137. extern void dn_dev_cleanup(void);
  138. extern int dn_dev_ioctl(unsigned int cmd, void __user *arg);
  139. extern void dn_dev_devices_off(void);
  140. extern void dn_dev_devices_on(void);
  141. extern void dn_dev_init_pkt(struct sk_buff *skb);
  142. extern void dn_dev_veri_pkt(struct sk_buff *skb);
  143. extern void dn_dev_hello(struct sk_buff *skb);
  144. extern void dn_dev_up(struct net_device *);
  145. extern void dn_dev_down(struct net_device *);
  146. extern int dn_dev_set_default(struct net_device *dev, int force);
  147. extern struct net_device *dn_dev_get_default(void);
  148. extern int dn_dev_bind_default(__le16 *addr);
  149. extern int register_dnaddr_notifier(struct notifier_block *nb);
  150. extern int unregister_dnaddr_notifier(struct notifier_block *nb);
  151. static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
  152. {
  153. struct dn_dev *dn_db;
  154. struct dn_ifaddr *ifa;
  155. int res = 0;
  156. rcu_read_lock();
  157. dn_db = rcu_dereference(dev->dn_ptr);
  158. if (dn_db == NULL) {
  159. printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
  160. goto out;
  161. }
  162. for (ifa = rcu_dereference(dn_db->ifa_list);
  163. ifa != NULL;
  164. ifa = rcu_dereference(ifa->ifa_next))
  165. if ((addr ^ ifa->ifa_local) == 0) {
  166. res = 1;
  167. break;
  168. }
  169. out:
  170. rcu_read_unlock();
  171. return res;
  172. }
  173. #endif /* _NET_DN_DEV_H */