dn_dev.h 5.3 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3 4 5 6 7
#ifndef _NET_DN_DEV_H
#define _NET_DN_DEV_H


struct dn_dev;

struct dn_ifaddr {
8
	struct dn_ifaddr __rcu *ifa_next;
L
Linus Torvalds 已提交
9
	struct dn_dev    *ifa_dev;
10 11 12 13 14
	__le16            ifa_local;
	__le16            ifa_address;
	__u8              ifa_flags;
	__u8              ifa_scope;
	char              ifa_label[IFNAMSIZ];
15
	struct rcu_head   rcu;
L
Linus Torvalds 已提交
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
};

#define DN_DEV_S_RU  0 /* Run - working normally   */
#define DN_DEV_S_CR  1 /* Circuit Rejected         */
#define DN_DEV_S_DS  2 /* Data Link Start          */
#define DN_DEV_S_RI  3 /* Routing Layer Initialize */
#define DN_DEV_S_RV  4 /* Routing Layer Verify     */
#define DN_DEV_S_RC  5 /* Routing Layer Complete   */
#define DN_DEV_S_OF  6 /* Off                      */
#define DN_DEV_S_HA  7 /* Halt                     */


/*
 * The dn_dev_parms structure contains the set of parameters
 * for each device (hence inclusion in the dn_dev structure)
 * and an array is used to store the default types of supported
 * device (in dn_dev.c).
 *
 * The type field matches the ARPHRD_ constants and is used in
 * searching the list for supported devices when new devices
 * come up.
 *
 * The mode field is used to find out if a device is broadcast,
 * multipoint, or pointopoint. Please note that DECnet thinks
 * different ways about devices to the rest of the kernel
 * so the normal IFF_xxx flags are invalid here. For devices
 * which can be any combination of the previously mentioned
 * attributes, you can set this on a per device basis by
 * installing an up() routine.
 *
 * The device state field, defines the initial state in which the
 * device will come up. In the dn_dev structure, it is the actual
 * state.
 *
 * Things have changed here. I've killed timer1 since it's a user space
 * issue for a user space routing deamon to sort out. The kernel does
 * not need to be bothered with it.
 *
 * Timers:
 * t2 - Rate limit timer, min time between routing and hello messages
 * t3 - Hello timer, send hello messages when it expires
 *
 * Callbacks:
 * up() - Called to initialize device, return value can veto use of
 *        device with DECnet.
 * down() - Called to turn device off when it goes down
 * timer3() - Called once for each ifaddr when timer 3 goes off
 * 
 * sysctl - Hook for sysctl things
 *
 */
struct dn_dev_parms {
	int type;	          /* ARPHRD_xxx                         */
	int mode;	          /* Broadcast, Unicast, Mulitpoint     */
#define DN_DEV_BCAST  1
#define DN_DEV_UCAST  2
#define DN_DEV_MPOINT 4
	int state;                /* Initial state                      */
	int forwarding;	          /* 0=EndNode, 1=L1Router, 2=L2Router  */
	unsigned long t2;         /* Default value of t2                */
	unsigned long t3;         /* Default value of t3                */
	int priority;             /* Priority to be a router            */
	char *name;               /* Name for sysctl                    */
	int  (*up)(struct net_device *);
	void (*down)(struct net_device *);
	void (*timer3)(struct net_device *, struct dn_ifaddr *ifa);
	void *sysctl;
};


struct dn_dev {
87
	struct dn_ifaddr __rcu *ifa_list;
L
Linus Torvalds 已提交
88 89 90
	struct net_device *dev;
	struct dn_dev_parms parms;
	char use_long;
91 92
	struct timer_list timer;
	unsigned long t3;
L
Linus Torvalds 已提交
93
	struct neigh_parms *neigh_parms;
94
	__u8 addr[ETH_ALEN];
L
Linus Torvalds 已提交
95 96 97 98 99
	struct neighbour *router; /* Default router on circuit */
	struct neighbour *peer;   /* Peer on pointopoint links */
	unsigned long uptime;     /* Time device went up in jiffies */
};

E
Eric Dumazet 已提交
100
struct dn_short_packet {
101 102 103 104
	__u8    msgflg;
	__le16 dstnode;
	__le16 srcnode;
	__u8   forward;
E
Eric Dumazet 已提交
105
} __packed;
L
Linus Torvalds 已提交
106

E
Eric Dumazet 已提交
107
struct dn_long_packet {
108 109 110 111 112 113 114 115 116 117 118
	__u8   msgflg;
	__u8   d_area;
	__u8   d_subarea;
	__u8   d_id[6];
	__u8   s_area;
	__u8   s_subarea;
	__u8   s_id[6];
	__u8   nl2;
	__u8   visit_ct;
	__u8   s_class;
	__u8   pt;
E
Eric Dumazet 已提交
119
} __packed;
L
Linus Torvalds 已提交
120 121 122

/*------------------------- DRP - Routing messages ---------------------*/

E
Eric Dumazet 已提交
123
struct endnode_hello_message {
124 125 126 127 128 129 130 131 132 133 134 135
	__u8   msgflg;
	__u8   tiver[3];
	__u8   id[6];
	__u8   iinfo;
	__le16 blksize;
	__u8   area;
	__u8   seed[8];
	__u8   neighbor[6];
	__le16 timer;
	__u8   mpd;
	__u8   datalen;
	__u8   data[2];
E
Eric Dumazet 已提交
136
} __packed;
L
Linus Torvalds 已提交
137

E
Eric Dumazet 已提交
138
struct rtnode_hello_message {
139 140 141 142 143 144 145 146 147
	__u8   msgflg;
	__u8   tiver[3];
	__u8   id[6];
	__u8   iinfo;
	__le16  blksize;
	__u8   priority;
	__u8   area;
	__le16  timer;
	__u8   mpd;
E
Eric Dumazet 已提交
148
} __packed;
L
Linus Torvalds 已提交
149 150


151 152
void dn_dev_init(void);
void dn_dev_cleanup(void);
L
Linus Torvalds 已提交
153

154
int dn_dev_ioctl(unsigned int cmd, void __user *arg);
L
Linus Torvalds 已提交
155

156 157
void dn_dev_devices_off(void);
void dn_dev_devices_on(void);
L
Linus Torvalds 已提交
158

159 160 161
void dn_dev_init_pkt(struct sk_buff *skb);
void dn_dev_veri_pkt(struct sk_buff *skb);
void dn_dev_hello(struct sk_buff *skb);
L
Linus Torvalds 已提交
162

163 164
void dn_dev_up(struct net_device *);
void dn_dev_down(struct net_device *);
L
Linus Torvalds 已提交
165

166 167 168
int dn_dev_set_default(struct net_device *dev, int force);
struct net_device *dn_dev_get_default(void);
int dn_dev_bind_default(__le16 *addr);
L
Linus Torvalds 已提交
169

170 171
int register_dnaddr_notifier(struct notifier_block *nb);
int unregister_dnaddr_notifier(struct notifier_block *nb);
L
Linus Torvalds 已提交
172

173
static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
L
Linus Torvalds 已提交
174
{
175
	struct dn_dev *dn_db;
L
Linus Torvalds 已提交
176
	struct dn_ifaddr *ifa;
177
	int res = 0;
L
Linus Torvalds 已提交
178

179 180
	rcu_read_lock();
	dn_db = rcu_dereference(dev->dn_ptr);
L
Linus Torvalds 已提交
181 182
	if (dn_db == NULL) {
		printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
183
		goto out;
L
Linus Torvalds 已提交
184 185
	}

186 187 188 189 190 191 192 193 194 195
	for (ifa = rcu_dereference(dn_db->ifa_list);
	     ifa != NULL;
	     ifa = rcu_dereference(ifa->ifa_next))
		if ((addr ^ ifa->ifa_local) == 0) {
			res = 1;
			break;
		}
out:
	rcu_read_unlock();
	return res;
L
Linus Torvalds 已提交
196 197 198
}

#endif /* _NET_DN_DEV_H */