dn_dev.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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 ctl_name; /* Index 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 *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. {
  93. __u8 msgflg;
  94. __le16 dstnode;
  95. __le16 srcnode;
  96. __u8 forward;
  97. } __attribute__((packed));
  98. struct dn_long_packet
  99. {
  100. __u8 msgflg;
  101. __u8 d_area;
  102. __u8 d_subarea;
  103. __u8 d_id[6];
  104. __u8 s_area;
  105. __u8 s_subarea;
  106. __u8 s_id[6];
  107. __u8 nl2;
  108. __u8 visit_ct;
  109. __u8 s_class;
  110. __u8 pt;
  111. } __attribute__((packed));
  112. /*------------------------- DRP - Routing messages ---------------------*/
  113. struct endnode_hello_message
  114. {
  115. __u8 msgflg;
  116. __u8 tiver[3];
  117. __u8 id[6];
  118. __u8 iinfo;
  119. __le16 blksize;
  120. __u8 area;
  121. __u8 seed[8];
  122. __u8 neighbor[6];
  123. __le16 timer;
  124. __u8 mpd;
  125. __u8 datalen;
  126. __u8 data[2];
  127. } __attribute__((packed));
  128. struct rtnode_hello_message
  129. {
  130. __u8 msgflg;
  131. __u8 tiver[3];
  132. __u8 id[6];
  133. __u8 iinfo;
  134. __le16 blksize;
  135. __u8 priority;
  136. __u8 area;
  137. __le16 timer;
  138. __u8 mpd;
  139. } __attribute__((packed));
  140. extern void dn_dev_init(void);
  141. extern void dn_dev_cleanup(void);
  142. extern int dn_dev_ioctl(unsigned int cmd, void __user *arg);
  143. extern void dn_dev_devices_off(void);
  144. extern void dn_dev_devices_on(void);
  145. extern void dn_dev_init_pkt(struct sk_buff *skb);
  146. extern void dn_dev_veri_pkt(struct sk_buff *skb);
  147. extern void dn_dev_hello(struct sk_buff *skb);
  148. extern void dn_dev_up(struct net_device *);
  149. extern void dn_dev_down(struct net_device *);
  150. extern int dn_dev_set_default(struct net_device *dev, int force);
  151. extern struct net_device *dn_dev_get_default(void);
  152. extern int dn_dev_bind_default(__le16 *addr);
  153. extern int register_dnaddr_notifier(struct notifier_block *nb);
  154. extern int unregister_dnaddr_notifier(struct notifier_block *nb);
  155. static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
  156. {
  157. struct dn_dev *dn_db = dev->dn_ptr;
  158. struct dn_ifaddr *ifa;
  159. if (dn_db == NULL) {
  160. printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
  161. return 0;
  162. }
  163. for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next)
  164. if ((addr ^ ifa->ifa_local) == 0)
  165. return 1;
  166. return 0;
  167. }
  168. #endif /* _NET_DN_DEV_H */