// SPDX-License-Identifier: GPL-2.0-only /* * Generic HDLC support routines for Linux * * Copyright (C) 1999 - 2008 Krzysztof Halasa <khc@pm.waw.pl> * * Currently supported: * * raw IP-in-HDLC * * Cisco HDLC * * Frame Relay with ANSI or CCITT LMI (both user and network side) * * PPP * * X.25 * * Use sethdlc utility to set line parameters, protocol and PVCs * * How does it work: * - proto->open(), close(), start(), stop() calls are serialized. * The order is: open, [ start, stop ... ] close ... * - proto->start() and stop() are called with spin_lock_irq held.
*/
/* Must be called by hardware driver when HDLC device is being opened */ int hdlc_open(struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK
printk(KERN_DEBUG "%s: hdlc_open() carrier %i open %i\n", dev->name,
hdlc->carrier, hdlc->open); #endif
if (!hdlc->proto) return -ENOSYS; /* no protocol attached */
if (hdlc->proto->open) { int result = hdlc->proto->open(dev);
if (result) return result;
}
spin_lock_irq(&hdlc->state_lock);
if (hdlc->carrier) {
netdev_info(dev, "Carrier detected\n");
hdlc_proto_start(dev);
} else {
netdev_info(dev, "No carrier\n");
}
/* Must be called by hardware driver when HDLC device is being closed */ void hdlc_close(struct net_device *dev)
{
hdlc_device *hdlc = dev_to_hdlc(dev); #ifdef DEBUG_LINK
printk(KERN_DEBUG "%s: hdlc_close() carrier %i open %i\n", dev->name,
hdlc->carrier, hdlc->open); #endif
spin_lock_irq(&hdlc->state_lock);
hdlc->open = 0; if (hdlc->carrier)
hdlc_proto_stop(dev);
spin_unlock_irq(&hdlc->state_lock);
if (hdlc->proto->close)
hdlc->proto->close(dev);
}
EXPORT_SYMBOL(hdlc_close);
int hdlc_ioctl(struct net_device *dev, struct if_settings *ifs)
{ struct hdlc_proto *proto = first_proto; int result;
if (dev_to_hdlc(dev)->proto) {
result = dev_to_hdlc(dev)->proto->ioctl(dev, ifs); if (result != -EINVAL) return result;
}
/* Not handled by currently attached protocol (if any) */
while (proto) {
result = proto->ioctl(dev, ifs); if (result != -EINVAL) return result;
proto = proto->next;
} return -EINVAL;
}
EXPORT_SYMBOL(hdlc_ioctl);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.