blob: 197886cd7bddad9a5099ce590c64569fdd619753 [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 {
Eric Dumazetfc766e4c2010-10-29 03:09:24 +00008 struct dn_ifaddr __rcu *ifa_next;
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 struct dn_dev *ifa_dev;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080010 __le16 ifa_local;
11 __le16 ifa_address;
Jiri Pirko9a32b862013-12-08 12:16:09 +010012 __u32 ifa_flags;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080013 __u8 ifa_scope;
14 char ifa_label[IFNAMSIZ];
Eric Dumazetfc766e4c2010-10-29 03:09:24 +000015 struct rcu_head rcu;
Linus Torvalds1da177e2005-04-16 15:20:36 -070016};
17
18#define DN_DEV_S_RU 0 /* Run - working normally */
19#define DN_DEV_S_CR 1 /* Circuit Rejected */
20#define DN_DEV_S_DS 2 /* Data Link Start */
21#define DN_DEV_S_RI 3 /* Routing Layer Initialize */
22#define DN_DEV_S_RV 4 /* Routing Layer Verify */
23#define DN_DEV_S_RC 5 /* Routing Layer Complete */
24#define DN_DEV_S_OF 6 /* Off */
25#define DN_DEV_S_HA 7 /* Halt */
26
27
28/*
29 * The dn_dev_parms structure contains the set of parameters
30 * for each device (hence inclusion in the dn_dev structure)
31 * and an array is used to store the default types of supported
32 * device (in dn_dev.c).
33 *
34 * The type field matches the ARPHRD_ constants and is used in
35 * searching the list for supported devices when new devices
36 * come up.
37 *
38 * The mode field is used to find out if a device is broadcast,
39 * multipoint, or pointopoint. Please note that DECnet thinks
40 * different ways about devices to the rest of the kernel
41 * so the normal IFF_xxx flags are invalid here. For devices
42 * which can be any combination of the previously mentioned
43 * attributes, you can set this on a per device basis by
44 * installing an up() routine.
45 *
46 * The device state field, defines the initial state in which the
47 * device will come up. In the dn_dev structure, it is the actual
48 * state.
49 *
50 * Things have changed here. I've killed timer1 since it's a user space
51 * issue for a user space routing deamon to sort out. The kernel does
52 * not need to be bothered with it.
53 *
54 * Timers:
55 * t2 - Rate limit timer, min time between routing and hello messages
56 * t3 - Hello timer, send hello messages when it expires
57 *
58 * Callbacks:
59 * up() - Called to initialize device, return value can veto use of
60 * device with DECnet.
61 * down() - Called to turn device off when it goes down
62 * timer3() - Called once for each ifaddr when timer 3 goes off
63 *
64 * sysctl - Hook for sysctl things
65 *
66 */
67struct dn_dev_parms {
68 int type; /* ARPHRD_xxx */
69 int mode; /* Broadcast, Unicast, Mulitpoint */
70#define DN_DEV_BCAST 1
71#define DN_DEV_UCAST 2
72#define DN_DEV_MPOINT 4
73 int state; /* Initial state */
74 int forwarding; /* 0=EndNode, 1=L1Router, 2=L2Router */
75 unsigned long t2; /* Default value of t2 */
76 unsigned long t3; /* Default value of t3 */
77 int priority; /* Priority to be a router */
78 char *name; /* Name for sysctl */
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 int (*up)(struct net_device *);
80 void (*down)(struct net_device *);
81 void (*timer3)(struct net_device *, struct dn_ifaddr *ifa);
82 void *sysctl;
83};
84
85
86struct dn_dev {
Eric Dumazetfc766e4c2010-10-29 03:09:24 +000087 struct dn_ifaddr __rcu *ifa_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 struct net_device *dev;
89 struct dn_dev_parms parms;
90 char use_long;
Jan Blunck6a878182006-01-08 01:05:07 -080091 struct timer_list timer;
92 unsigned long t3;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 struct neigh_parms *neigh_parms;
Steven Whitehousec4ea94a2006-03-20 22:42:39 -080094 __u8 addr[ETH_ALEN];
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 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
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000100struct dn_short_packet {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800101 __u8 msgflg;
102 __le16 dstnode;
103 __le16 srcnode;
104 __u8 forward;
Eric Dumazetbc105022010-06-03 03:21:52 -0700105} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000107struct dn_long_packet {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800108 __u8 msgflg;
109 __u8 d_area;
110 __u8 d_subarea;
111 __u8 d_id[6];
112 __u8 s_area;
113 __u8 s_subarea;
114 __u8 s_id[6];
115 __u8 nl2;
116 __u8 visit_ct;
117 __u8 s_class;
118 __u8 pt;
Eric Dumazetbc105022010-06-03 03:21:52 -0700119} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121/*------------------------- DRP - Routing messages ---------------------*/
122
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000123struct endnode_hello_message {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800124 __u8 msgflg;
125 __u8 tiver[3];
126 __u8 id[6];
127 __u8 iinfo;
128 __le16 blksize;
129 __u8 area;
130 __u8 seed[8];
131 __u8 neighbor[6];
132 __le16 timer;
133 __u8 mpd;
134 __u8 datalen;
135 __u8 data[2];
Eric Dumazetbc105022010-06-03 03:21:52 -0700136} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
Eric Dumazetfd2c3ef2009-11-03 03:26:03 +0000138struct rtnode_hello_message {
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800139 __u8 msgflg;
140 __u8 tiver[3];
141 __u8 id[6];
142 __u8 iinfo;
143 __le16 blksize;
144 __u8 priority;
145 __u8 area;
146 __le16 timer;
147 __u8 mpd;
Eric Dumazetbc105022010-06-03 03:21:52 -0700148} __packed;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150
Joe Perches59ddd962013-09-20 11:23:20 -0700151void dn_dev_init(void);
152void dn_dev_cleanup(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Joe Perches59ddd962013-09-20 11:23:20 -0700154int dn_dev_ioctl(unsigned int cmd, void __user *arg);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Joe Perches59ddd962013-09-20 11:23:20 -0700156void dn_dev_devices_off(void);
157void dn_dev_devices_on(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158
Joe Perches59ddd962013-09-20 11:23:20 -0700159void dn_dev_init_pkt(struct sk_buff *skb);
160void dn_dev_veri_pkt(struct sk_buff *skb);
161void dn_dev_hello(struct sk_buff *skb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Joe Perches59ddd962013-09-20 11:23:20 -0700163void dn_dev_up(struct net_device *);
164void dn_dev_down(struct net_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165
Joe Perches59ddd962013-09-20 11:23:20 -0700166int dn_dev_set_default(struct net_device *dev, int force);
167struct net_device *dn_dev_get_default(void);
168int dn_dev_bind_default(__le16 *addr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Joe Perches59ddd962013-09-20 11:23:20 -0700170int register_dnaddr_notifier(struct notifier_block *nb);
171int unregister_dnaddr_notifier(struct notifier_block *nb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172
Steven Whitehousec4ea94a2006-03-20 22:42:39 -0800173static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
Eric Dumazetfc766e4c2010-10-29 03:09:24 +0000175 struct dn_dev *dn_db;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 struct dn_ifaddr *ifa;
Eric Dumazetfc766e4c2010-10-29 03:09:24 +0000177 int res = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
Eric Dumazetfc766e4c2010-10-29 03:09:24 +0000179 rcu_read_lock();
180 dn_db = rcu_dereference(dev->dn_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181 if (dn_db == NULL) {
182 printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
Eric Dumazetfc766e4c2010-10-29 03:09:24 +0000183 goto out;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
185
Eric Dumazetfc766e4c2010-10-29 03:09:24 +0000186 for (ifa = rcu_dereference(dn_db->ifa_list);
187 ifa != NULL;
188 ifa = rcu_dereference(ifa->ifa_next))
189 if ((addr ^ ifa->ifa_local) == 0) {
190 res = 1;
191 break;
192 }
193out:
194 rcu_read_unlock();
195 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196}
197
198#endif /* _NET_DN_DEV_H */