GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / include / linux / hdlc.h
blob97ef07eef96997fb9fe11b940cebfd0aa4a5cd23
1 /*
2 * Generic HDLC support routines for Linux
4 * Copyright (C) 1999-2005 Krzysztof Halasa <khc@pm.waw.pl>
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 */
11 #ifndef __HDLC_H
12 #define __HDLC_H
15 #define HDLC_MAX_MTU 1500 /* Ethernet 1500 bytes */
16 #define HDLC_MAX_MRU 1600 /* as required for FR network */
19 #ifdef __KERNEL__
21 #include <linux/skbuff.h>
22 #include <linux/netdevice.h>
23 #include <linux/hdlc/ioctl.h>
25 /* This structure is a private property of HDLC protocols.
26 Hardware drivers have no interest here */
28 struct hdlc_proto {
29 int (*open)(struct net_device *dev);
30 void (*close)(struct net_device *dev);
31 void (*start)(struct net_device *dev); /* if open & DCD */
32 void (*stop)(struct net_device *dev); /* if open & !DCD */
33 void (*detach)(struct net_device *dev);
34 int (*ioctl)(struct net_device *dev, struct ifreq *ifr);
35 __be16 (*type_trans)(struct sk_buff *skb, struct net_device *dev);
36 int (*netif_rx)(struct sk_buff *skb);
37 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
38 struct module *module;
39 struct hdlc_proto *next; /* next protocol in the list */
43 /* Pointed to by netdev_priv(dev) */
44 typedef struct hdlc_device {
45 /* used by HDLC layer to take control over HDLC device from hw driver*/
46 int (*attach)(struct net_device *dev,
47 unsigned short encoding, unsigned short parity);
49 /* hardware driver must handle this instead of dev->hard_start_xmit */
50 netdev_tx_t (*xmit)(struct sk_buff *skb, struct net_device *dev);
52 /* Things below are for HDLC layer internal use only */
53 const struct hdlc_proto *proto;
54 int carrier;
55 int open;
56 spinlock_t state_lock;
57 void *state;
58 void *priv;
59 } hdlc_device;
63 /* Exported from hdlc module */
65 /* Called by hardware driver when a user requests HDLC service */
66 int hdlc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
68 /* Must be used by hardware driver on module startup/exit */
69 #define register_hdlc_device(dev) register_netdev(dev)
70 void unregister_hdlc_device(struct net_device *dev);
73 void register_hdlc_protocol(struct hdlc_proto *proto);
74 void unregister_hdlc_protocol(struct hdlc_proto *proto);
76 struct net_device *alloc_hdlcdev(void *priv);
78 static inline struct hdlc_device* dev_to_hdlc(struct net_device *dev)
80 return netdev_priv(dev);
83 static __inline__ void debug_frame(const struct sk_buff *skb)
85 int i;
87 for (i=0; i < skb->len; i++) {
88 if (i == 100) {
89 printk("...\n");
90 return;
92 printk(" %02X", skb->data[i]);
94 printk("\n");
98 /* Must be called by hardware driver when HDLC device is being opened */
99 int hdlc_open(struct net_device *dev);
100 /* Must be called by hardware driver when HDLC device is being closed */
101 void hdlc_close(struct net_device *dev);
102 /* May be used by hardware driver */
103 int hdlc_change_mtu(struct net_device *dev, int new_mtu);
104 /* Must be pointed to by hw driver's dev->netdev_ops->ndo_start_xmit */
105 netdev_tx_t hdlc_start_xmit(struct sk_buff *skb, struct net_device *dev);
107 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
108 size_t size);
109 /* May be used by hardware driver to gain control over HDLC device */
110 void detach_hdlc_protocol(struct net_device *dev);
112 static __inline__ __be16 hdlc_type_trans(struct sk_buff *skb,
113 struct net_device *dev)
115 hdlc_device *hdlc = dev_to_hdlc(dev);
117 skb->dev = dev;
118 skb_reset_mac_header(skb);
120 if (hdlc->proto->type_trans)
121 return hdlc->proto->type_trans(skb, dev);
122 else
123 return htons(ETH_P_HDLC);
126 #endif /* __KERNEL */
127 #endif /* __HDLC_H */