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