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