Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _NET_DN_DEV_H
0003 #define _NET_DN_DEV_H
0004 
0005 #include <linux/netdevice.h>
0006 
0007 struct dn_dev;
0008 
0009 struct dn_ifaddr {
0010     struct dn_ifaddr __rcu *ifa_next;
0011     struct dn_dev    *ifa_dev;
0012     __le16            ifa_local;
0013     __le16            ifa_address;
0014     __u32             ifa_flags;
0015     __u8              ifa_scope;
0016     char              ifa_label[IFNAMSIZ];
0017     struct rcu_head   rcu;
0018 };
0019 
0020 #define DN_DEV_S_RU  0 /* Run - working normally   */
0021 #define DN_DEV_S_CR  1 /* Circuit Rejected         */
0022 #define DN_DEV_S_DS  2 /* Data Link Start          */
0023 #define DN_DEV_S_RI  3 /* Routing Layer Initialize */
0024 #define DN_DEV_S_RV  4 /* Routing Layer Verify     */
0025 #define DN_DEV_S_RC  5 /* Routing Layer Complete   */
0026 #define DN_DEV_S_OF  6 /* Off                      */
0027 #define DN_DEV_S_HA  7 /* Halt                     */
0028 
0029 
0030 /*
0031  * The dn_dev_parms structure contains the set of parameters
0032  * for each device (hence inclusion in the dn_dev structure)
0033  * and an array is used to store the default types of supported
0034  * device (in dn_dev.c).
0035  *
0036  * The type field matches the ARPHRD_ constants and is used in
0037  * searching the list for supported devices when new devices
0038  * come up.
0039  *
0040  * The mode field is used to find out if a device is broadcast,
0041  * multipoint, or pointopoint. Please note that DECnet thinks
0042  * different ways about devices to the rest of the kernel
0043  * so the normal IFF_xxx flags are invalid here. For devices
0044  * which can be any combination of the previously mentioned
0045  * attributes, you can set this on a per device basis by
0046  * installing an up() routine.
0047  *
0048  * The device state field, defines the initial state in which the
0049  * device will come up. In the dn_dev structure, it is the actual
0050  * state.
0051  *
0052  * Things have changed here. I've killed timer1 since it's a user space
0053  * issue for a user space routing deamon to sort out. The kernel does
0054  * not need to be bothered with it.
0055  *
0056  * Timers:
0057  * t2 - Rate limit timer, min time between routing and hello messages
0058  * t3 - Hello timer, send hello messages when it expires
0059  *
0060  * Callbacks:
0061  * up() - Called to initialize device, return value can veto use of
0062  *        device with DECnet.
0063  * down() - Called to turn device off when it goes down
0064  * timer3() - Called once for each ifaddr when timer 3 goes off
0065  * 
0066  * sysctl - Hook for sysctl things
0067  *
0068  */
0069 struct dn_dev_parms {
0070     int type;             /* ARPHRD_xxx                         */
0071     int mode;             /* Broadcast, Unicast, Mulitpoint     */
0072 #define DN_DEV_BCAST  1
0073 #define DN_DEV_UCAST  2
0074 #define DN_DEV_MPOINT 4
0075     int state;                /* Initial state                      */
0076     int forwarding;           /* 0=EndNode, 1=L1Router, 2=L2Router  */
0077     unsigned long t2;         /* Default value of t2                */
0078     unsigned long t3;         /* Default value of t3                */
0079     int priority;             /* Priority to be a router            */
0080     char *name;               /* Name for sysctl                    */
0081     int  (*up)(struct net_device *);
0082     void (*down)(struct net_device *);
0083     void (*timer3)(struct net_device *, struct dn_ifaddr *ifa);
0084     void *sysctl;
0085 };
0086 
0087 
0088 struct dn_dev {
0089     struct dn_ifaddr __rcu *ifa_list;
0090     struct net_device *dev;
0091     struct dn_dev_parms parms;
0092     char use_long;
0093     struct timer_list timer;
0094     unsigned long t3;
0095     struct neigh_parms *neigh_parms;
0096     __u8 addr[ETH_ALEN];
0097     struct neighbour *router; /* Default router on circuit */
0098     struct neighbour *peer;   /* Peer on pointopoint links */
0099     unsigned long uptime;     /* Time device went up in jiffies */
0100 };
0101 
0102 struct dn_short_packet {
0103     __u8    msgflg;
0104     __le16 dstnode;
0105     __le16 srcnode;
0106     __u8   forward;
0107 } __packed;
0108 
0109 struct dn_long_packet {
0110     __u8   msgflg;
0111     __u8   d_area;
0112     __u8   d_subarea;
0113     __u8   d_id[6];
0114     __u8   s_area;
0115     __u8   s_subarea;
0116     __u8   s_id[6];
0117     __u8   nl2;
0118     __u8   visit_ct;
0119     __u8   s_class;
0120     __u8   pt;
0121 } __packed;
0122 
0123 /*------------------------- DRP - Routing messages ---------------------*/
0124 
0125 struct endnode_hello_message {
0126     __u8   msgflg;
0127     __u8   tiver[3];
0128     __u8   id[6];
0129     __u8   iinfo;
0130     __le16 blksize;
0131     __u8   area;
0132     __u8   seed[8];
0133     __u8   neighbor[6];
0134     __le16 timer;
0135     __u8   mpd;
0136     __u8   datalen;
0137     __u8   data[2];
0138 } __packed;
0139 
0140 struct rtnode_hello_message {
0141     __u8   msgflg;
0142     __u8   tiver[3];
0143     __u8   id[6];
0144     __u8   iinfo;
0145     __le16  blksize;
0146     __u8   priority;
0147     __u8   area;
0148     __le16  timer;
0149     __u8   mpd;
0150 } __packed;
0151 
0152 
0153 void dn_dev_init(void);
0154 void dn_dev_cleanup(void);
0155 
0156 int dn_dev_ioctl(unsigned int cmd, void __user *arg);
0157 
0158 void dn_dev_devices_off(void);
0159 void dn_dev_devices_on(void);
0160 
0161 void dn_dev_init_pkt(struct sk_buff *skb);
0162 void dn_dev_veri_pkt(struct sk_buff *skb);
0163 void dn_dev_hello(struct sk_buff *skb);
0164 
0165 void dn_dev_up(struct net_device *);
0166 void dn_dev_down(struct net_device *);
0167 
0168 int dn_dev_set_default(struct net_device *dev, int force);
0169 struct net_device *dn_dev_get_default(void);
0170 int dn_dev_bind_default(__le16 *addr);
0171 
0172 int register_dnaddr_notifier(struct notifier_block *nb);
0173 int unregister_dnaddr_notifier(struct notifier_block *nb);
0174 
0175 static inline int dn_dev_islocal(struct net_device *dev, __le16 addr)
0176 {
0177     struct dn_dev *dn_db;
0178     struct dn_ifaddr *ifa;
0179     int res = 0;
0180 
0181     rcu_read_lock();
0182     dn_db = rcu_dereference(dev->dn_ptr);
0183     if (dn_db == NULL) {
0184         printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n");
0185         goto out;
0186     }
0187 
0188     for (ifa = rcu_dereference(dn_db->ifa_list);
0189          ifa != NULL;
0190          ifa = rcu_dereference(ifa->ifa_next))
0191         if ((addr ^ ifa->ifa_local) == 0) {
0192             res = 1;
0193             break;
0194         }
0195 out:
0196     rcu_read_unlock();
0197     return res;
0198 }
0199 
0200 #endif /* _NET_DN_DEV_H */