This source file includes following definitions.
- dev_to_hdlc
- debug_frame
- hdlc_type_trans
1
2
3
4
5
6
7 #ifndef __HDLC_H
8 #define __HDLC_H
9
10
11 #include <linux/skbuff.h>
12 #include <linux/netdevice.h>
13 #include <linux/hdlc/ioctl.h>
14 #include <uapi/linux/hdlc.h>
15
16
17
18
19 struct hdlc_proto {
20 int (*open)(struct net_device *dev);
21 void (*close)(struct net_device *dev);
22 void (*start)(struct net_device *dev);
23 void (*stop)(struct net_device *dev);
24 void (*detach)(struct net_device *dev);
25 int (*ioctl)(struct net_device *dev, struct ifreq *ifr);
26 __be16 (*type_trans)(struct sk_buff *skb, struct net_device *dev);
27 int (*netif_rx)(struct sk_buff *skb);
28 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
29 struct module *module;
30 struct hdlc_proto *next;
31 };
32
33
34
35 typedef struct hdlc_device {
36
37 int (*attach)(struct net_device *dev,
38 unsigned short encoding, unsigned short parity);
39
40
41 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
42
43
44 const struct hdlc_proto *proto;
45 int carrier;
46 int open;
47 spinlock_t state_lock;
48 void *state;
49 void *priv;
50 } hdlc_device;
51
52
53
54
55
56
57 int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
58
59
60 #define register_hdlc_device(dev) register_netdev(dev)
61 void unregister_hdlc_device(struct net_device *dev);
62
63
64 void register_hdlc_protocol(struct hdlc_proto *proto);
65 void unregister_hdlc_protocol(struct hdlc_proto *proto);
66
67 struct net_device *alloc_hdlcdev(void *priv);
68
69 static inline struct hdlc_device* dev_to_hdlc(struct net_device *dev)
70 {
71 return netdev_priv(dev);
72 }
73
74 static __inline__ void debug_frame(const struct sk_buff *skb)
75 {
76 int i;
77
78 for (i=0; i < skb->len; i++) {
79 if (i == 100) {
80 printk("...\n");
81 return;
82 }
83 printk(" %02X", skb->data[i]);
84 }
85 printk("\n");
86 }
87
88
89
90 int hdlc_open(struct net_device *dev);
91
92 void hdlc_close(struct net_device *dev);
93
94 netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev);
95
96 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
97 size_t size);
98
99 int detach_hdlc_protocol(struct net_device *dev);
100
101 static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
102 struct net_device *dev)
103 {
104 hdlc_device *hdlc = dev_to_hdlc(dev);
105
106 skb->dev = dev;
107 skb_reset_mac_header(skb);
108
109 if (hdlc->proto->type_trans)
110 return hdlc->proto->type_trans(skb, dev);
111 else
112 return htons(ETH_P_HDLC);
113 }
114
115 #endif