dn_dev.h 5.2 KB

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