// SPDX-License-Identifier: GPL-2.0-or-later /* * G8BPQ compatible "AX.25 via ethernet" driver release 004 * * This code REQUIRES 2.0.0 or higher/ NET3.029 * * This is a "pseudo" network driver to allow AX.25 over Ethernet * using G8BPQ encapsulation. It has been extracted from the protocol * implementation because * * - things got unreadable within the protocol stack * - to cure the protocol stack from "feature-ism" * - a protocol implementation shouldn't need to know on * which hardware it is running * - user-level programs like the AX.25 utilities shouldn't * need to know about the hardware. * - IP over ethernet encapsulated AX.25 was impossible * - rxecho.c did not work * - to have room for extensions * - it just deserves to "live" as an own driver * * This driver can use any ethernet destination address, and can be * limited to accept frames from one dedicated ethernet card only. * * Note that the driver sets up the BPQ devices automagically on * startup or (if started before the "insmod" of an ethernet device) * on "ifconfig up". It hopefully will remove the BPQ on "rmmod"ing * the ethernet device (in fact: as soon as another ethernet or bpq * device gets "ifconfig"ured). * * I have heard that several people are thinking of experiments * with highspeed packet radio using existing ethernet cards. * Well, this driver is prepared for this purpose, just add * your tx key control and a txdelay / tailtime algorithm, * probably some buffering, and /voila/... * * History * BPQ 001 Joerg(DL1BKE) Extracted BPQ code from AX.25 * protocol stack and added my own * yet existing patches * BPQ 002 Joerg(DL1BKE) Scan network device list on * startup. * BPQ 003 Joerg(DL1BKE) Ethernet destination address * and accepted source address * can be configured by an ioctl() * call. * Fixed to match Linux networking * changes - 2.1.15. * BPQ 004 Joerg(DL1BKE) Fixed to not lock up on ifconfig.
*/
/* * Send an AX.25 frame via an ethernet interface
*/ static netdev_tx_t bpq_xmit(struct sk_buff *skb, struct net_device *dev)
{ unsignedchar *ptr; struct bpqdev *bpq; struct net_device *orig_dev; int size;
if (skb->protocol == htons(ETH_P_IP)) return ax25_ip_xmit(skb);
/* * Just to be *really* sure not to send anything if the interface * is down, the ethernet device may have gone.
*/ if (!netif_running(dev)) {
kfree_skb(skb); return NETDEV_TX_OK;
}
skb_pull(skb, 1); /* Drop KISS byte */
size = skb->len;
/* * We're about to mess with the skb which may still shared with the * generic networking code so unshare and ensure it's got enough * space for the BPQ headers.
*/ if (skb_cow(skb, AX25_BPQ_HEADER_LEN)) { if (net_ratelimit())
pr_err("bpqether: out of memory\n");
kfree_skb(skb);
return NETDEV_TX_OK;
}
ptr = skb_push(skb, 2); /* Make space for length */
/* Ioctl commands * * SIOCSBPQETHOPT reserved for enhancements * SIOCSBPQETHADDR set the destination and accepted * source ethernet address (broadcast * or multicast: accept all)
*/ staticint bpq_siocdevprivate(struct net_device *dev, struct ifreq *ifr, void __user *data, int cmd)
{ struct bpq_ethaddr __user *ethaddr = data; struct bpqdev *bpq = netdev_priv(dev); struct bpq_req req;
if (!capable(CAP_NET_ADMIN)) return -EPERM;
switch (cmd) { case SIOCSBPQETHOPT: if (copy_from_user(&req, data, sizeof(struct bpq_req))) return -EFAULT; switch (req.cmd) { case SIOCGBPQETHPARAM: case SIOCSBPQETHPARAM: default: return -EINVAL;
}
break;
case SIOCSBPQETHADDR: if (copy_from_user(bpq->dest_addr, ethaddr->destination, ETH_ALEN)) return -EFAULT; if (copy_from_user(bpq->acpt_addr, ethaddr->accept, ETH_ALEN)) return -EFAULT; break;
/* * Initialize driver. To be called from af_ax25 if not compiled as a * module
*/ staticint __init bpq_init_driver(void)
{ #ifdef CONFIG_PROC_FS if (!proc_create_seq("bpqether", 0444, init_net.proc_net, &bpq_seqops)) {
printk(KERN_ERR "bpq: cannot create /proc/net/bpqether entry.\n"); return -ENOENT;
} #endif/* CONFIG_PROC_FS */
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.