blob: 511a459ec10f8684cab539669f6e64c85e18967b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#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;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080010 __le16 ifa_local;
11 __le16 ifa_address;
12 __u8 ifa_flags;
13 __u8 ifa_scope;
14 char ifa_label[IFNAMSIZ];
Linus Torvalds1da177e2005-04-16 15:20:36 -070015};
16
17#define DN_DEV_S_RU 0 /* Run - working normally */
18#define DN_DEV_S_CR 1 /* Circuit Rejected */
19#define DN_DEV_S_DS 2 /* Data Link Start */
20#define DN_DEV_S_RI 3 /* Routing Layer Initialize */
21#define DN_DEV_S_RV 4 /* Routing Layer Verify */
22#define DN_DEV_S_RC 5 /* Routing Layer Complete */
23#define DN_DEV_S_OF 6 /* Off */
24#define DN_DEV_S_HA 7 /* Halt */
25
26
27/*
28 * The dn_dev_parms structure contains the set of parameters
29 * for each device (hence inclusion in the dn_dev structure)
30 * and an array is used to store the default types of supported
31 * device (in dn_dev.c).
32 *
33 * The type field matches the ARPHRD_ constants and is used in
34 * searching the list for supported devices when new devices
35 * come up.
36 *
37 * The mode field is used to find out if a device is broadcast,
38 * multipoint, or pointopoint. Please note that DECnet thinks
39 * different ways about devices to the rest of the kernel
40 * so the normal IFF_xxx flags are invalid here. For devices
41 * which can be any combination of the previously mentioned
42 * attributes, you can set this on a per device basis by
43 * installing an up() routine.
44 *
45 * The device state field, defines the initial state in which the
46 * device will come up. In the dn_dev structure, it is the actual
47 * state.
48 *
49 * Things have changed here. I've killed timer1 since it's a user space
50 * issue for a user space routing deamon to sort out. The kernel does
51 * not need to be bothered with it.
52 *
53 * Timers:
54 * t2 - Rate limit timer, min time between routing and hello messages
55 * t3 - Hello timer, send hello messages when it expires
56 *
57 * Callbacks:
58 * up() - Called to initialize device, return value can veto use of
59 * device with DECnet.
60 * down() - Called to turn device off when it goes down
61 * timer3() - Called once for each ifaddr when timer 3 goes off
62 *
63 * sysctl - Hook for sysctl things
64 *
65 */
66struct dn_dev_parms {
67 int type; /* ARPHRD_xxx */
68 int mode; /* Broadcast, Unicast, Mulitpoint */
69#define DN_DEV_BCAST 1
70#define DN_DEV_UCAST 2
71#define DN_DEV_MPOINT 4
72 int state; /* Initial state */
73 int forwarding; /* 0=EndNode, 1=L1Router, 2=L2Router */
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 int (*up)(struct net_device *);
79 void (*down)(struct net_device *);
80 void (*timer3)(struct net_device *, struct dn_ifaddr *ifa);
81 void *sysctl;
82};
83
84
85struct dn_dev {
86 struct dn_ifaddr *ifa_list;
87 struct net_device *dev;
88 struct dn_dev_parms parms;
89 char use_long;
Jan Blunck6a878182006-01-08 01:05:07 -080090 struct timer_list timer;
91 unsigned long t3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 struct neigh_parms *neigh_parms;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080093 __u8 addr[ETH_ALEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 struct neighbour *router; /* Default router on circuit */
95 struct neighbour *peer; /* Peer on pointopoint links */
96 unsigned long uptime; /* Time device went up in jiffies */
97};
98
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +000099struct dn_short_packet {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800100 __u8 msgflg;
101 __le16 dstnode;
102 __le16 srcnode;
103 __u8 forward;
Jan Blunck6a878182006-01-08 01:05:07 -0800104} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000106struct dn_long_packet {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800107 __u8 msgflg;
108 __u8 d_area;
109 __u8 d_subarea;
110 __u8 d_id[6];
111 __u8 s_area;
112 __u8 s_subarea;
113 __u8 s_id[6];
114 __u8 nl2;
115 __u8 visit_ct;
116 __u8 s_class;
117 __u8 pt;
Jan Blunck6a878182006-01-08 01:05:07 -0800118} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120/*------------------------- DRP - Routing messages ---------------------*/
121
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000122struct endnode_hello_message {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800123 __u8 msgflg;
124 __u8 tiver[3];
125 __u8 id[6];
126 __u8 iinfo;
127 __le16 blksize;
128 __u8 area;
129 __u8 seed[8];
130 __u8 neighbor[6];
131 __le16 timer;
132 __u8 mpd;
133 __u8 datalen;
134 __u8 data[2];
Jan Blunck6a878182006-01-08 01:05:07 -0800135} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000137struct rtnode_hello_message {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800138 __u8 msgflg;
139 __u8 tiver[3];
140 __u8 id[6];
141 __u8 iinfo;
142 __le16 blksize;
143 __u8 priority;
144 __u8 area;
145 __le16 timer;
146 __u8 mpd;
Jan Blunck6a878182006-01-08 01:05:07 -0800147} __attribute__((packed));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148
149
150extern void dn_dev_init(void);
151extern void dn_dev_cleanup(void);
152
153extern int dn_dev_ioctl(unsigned int cmd, void __user *arg);
154
155extern void dn_dev_devices_off(void);
156extern void dn_dev_devices_on(void);
157
158extern void dn_dev_init_pkt(struct sk_buff *skb);
159extern void dn_dev_veri_pkt(struct sk_buff *skb);
160extern void dn_dev_hello(struct sk_buff *skb);
161
162extern void dn_dev_up(struct net_device *);
163extern void dn_dev_down(struct net_device *);
164
165extern int dn_dev_set_default(struct net_device *dev, int force);
166extern struct net_device *dn_dev_get_default(void);
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800167extern int dn_dev_bind_default(__le16 *addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169extern int register_dnaddr_notifier(struct notifier_block *nb);
170extern int unregister_dnaddr_notifier(struct notifier_block *nb);
171
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800172static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173{
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 */