~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/hdlc.h

Version: ~ [ linux-5.6-rc1 ] ~ [ linux-5.5.2 ] ~ [ linux-5.4.17 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.102 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.170 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.213 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.213 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * Generic HDLC support routines for Linux
  3  *
  4  * Copyright (C) 1999-2005 Krzysztof Halasa <khc@pm.waw.pl>
  5  *
  6  * This program is free software; you can redistribute it and/or modify it
  7  * under the terms of version 2 of the GNU General Public License
  8  * as published by the Free Software Foundation.
  9  */
 10 #ifndef __HDLC_H
 11 #define __HDLC_H
 12 
 13 
 14 #include <linux/skbuff.h>
 15 #include <linux/netdevice.h>
 16 #include <linux/hdlc/ioctl.h>
 17 #include <uapi/linux/hdlc.h>
 18 
 19 /* This structure is a private property of HDLC protocols.
 20    Hardware drivers have no interest here */
 21 
 22 struct hdlc_proto {
 23         int (*open)(struct net_device *dev);
 24         void (*close)(struct net_device *dev);
 25         void (*start)(struct net_device *dev); /* if open & DCD */
 26         void (*stop)(struct net_device *dev); /* if open & !DCD */
 27         void (*detach)(struct net_device *dev);
 28         int (*ioctl)(struct net_device *dev, struct ifreq *ifr);
 29         __be16 (*type_trans)(struct sk_buff *skb, struct net_device *dev);
 30         int (*netif_rx)(struct sk_buff *skb);
 31         netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
 32         struct module *module;
 33         struct hdlc_proto *next; /* next protocol in the list */
 34 };
 35 
 36 
 37 /* Pointed to by netdev_priv(dev) */
 38 typedef struct hdlc_device {
 39         /* used by HDLC layer to take control over HDLC device from hw driver*/
 40         int (*attach)(struct net_device *dev,
 41                       unsigned short encoding, unsigned short parity);
 42 
 43         /* hardware driver must handle this instead of dev->hard_start_xmit */
 44         netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
 45 
 46         /* Things below are for HDLC layer internal use only */
 47         const struct hdlc_proto *proto;
 48         int carrier;
 49         int open;
 50         spinlock_t state_lock;
 51         void *state;
 52         void *priv;
 53 } hdlc_device;
 54 
 55 
 56 
 57 /* Exported from hdlc module */
 58 
 59 /* Called by hardware driver when a user requests HDLC service */
 60 int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
 61 
 62 /* Must be used by hardware driver on module startup/exit */
 63 #define register_hdlc_device(dev)       register_netdev(dev)
 64 void unregister_hdlc_device(struct net_device *dev);
 65 
 66 
 67 void register_hdlc_protocol(struct hdlc_proto *proto);
 68 void unregister_hdlc_protocol(struct hdlc_proto *proto);
 69 
 70 struct net_device *alloc_hdlcdev(void *priv);
 71 
 72 static inline struct hdlc_device* dev_to_hdlc(struct net_device *dev)
 73 {
 74         return netdev_priv(dev);
 75 }
 76 
 77 static __inline__ void debug_frame(const struct sk_buff *skb)
 78 {
 79         int i;
 80 
 81         for (i=0; i < skb->len; i++) {
 82                 if (i == 100) {
 83                         printk("...\n");
 84                         return;
 85                 }
 86                 printk(" %02X", skb->data[i]);
 87         }
 88         printk("\n");
 89 }
 90 
 91 
 92 /* Must be called by hardware driver when HDLC device is being opened */
 93 int hdlc_open(struct net_device *dev);
 94 /* Must be called by hardware driver when HDLC device is being closed */
 95 void hdlc_close(struct net_device *dev);
 96 /* May be used by hardware driver */
 97 int hdlc_change_mtu(struct net_device *dev, int new_mtu);
 98 /* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */
 99 netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev);
100 
101 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
102                          size_t size);
103 /* May be used by hardware driver to gain control over HDLC device */
104 void detach_hdlc_protocol(struct net_device *dev);
105 
106 static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
107                                          struct net_device *dev)
108 {
109         hdlc_device *hdlc = dev_to_hdlc(dev);
110 
111         skb->dev = dev;
112         skb_reset_mac_header(skb);
113 
114         if (hdlc->proto->type_trans)
115                 return hdlc->proto->type_trans(skb, dev);
116         else
117                 return htons(ETH_P_HDLC);
118 }
119 
120 #endif /* __HDLC_H */
121 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp