// SPDX-License-Identifier: GPL-2.0-or-later /* * X.25 Packet Layer release 002 * * This is ALPHA test software. This code may break your machine, * randomly fail to work with new releases, misbehave and/or generally * screw up. It might even work. * * This code REQUIRES 2.1.15 or higher * * History * X.25 001 Jonathan Naylor Started coding. * X.25 002 Jonathan Naylor New timer architecture. * mar/20/00 Daniela Squassoni Disabling/enabling of facilities * negotiation. * 2000-09-04 Henner Eisen dev_hold() / dev_put() for x25_neigh.
*/
/* * This handles all restart and diagnostic frames.
*/ void x25_link_control(struct sk_buff *skb, struct x25_neigh *nb, unsignedshort frametype)
{ struct sk_buff *skbn;
switch (frametype) { case X25_RESTART_REQUEST: switch (nb->state) { case X25_LINK_STATE_0: /* This can happen when the x25 module just gets loaded * and doesn't know layer 2 has already connected
*/
nb->state = X25_LINK_STATE_3;
x25_transmit_restart_confirmation(nb); break; case X25_LINK_STATE_2:
x25_stop_t20timer(nb);
nb->state = X25_LINK_STATE_3; break; case X25_LINK_STATE_3: /* clear existing virtual calls */
x25_kill_by_neigh(nb);
default:
pr_warn("received unknown %02X with LCI 000\n",
frametype); break;
}
if (nb->state == X25_LINK_STATE_3) while ((skbn = skb_dequeue(&nb->queue)) != NULL)
x25_send_frame(skbn, nb);
}
/* * This routine is called when a Restart Request is needed
*/ staticvoid x25_transmit_restart_request(struct x25_neigh *nb)
{ unsignedchar *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC);
/* * This routine is called when a Restart Confirmation is needed
*/ staticvoid x25_transmit_restart_confirmation(struct x25_neigh *nb)
{ unsignedchar *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC);
/* * This routine is called when a Clear Request is needed outside of the context * of a connected socket.
*/ void x25_transmit_clear_request(struct x25_neigh *nb, unsignedint lci, unsignedchar cause)
{ unsignedchar *dptr; int len = X25_MAX_L2_LEN + X25_STD_MIN_LEN + 2; struct sk_buff *skb = alloc_skb(len, GFP_ATOMIC);
void x25_transmit_link(struct sk_buff *skb, struct x25_neigh *nb)
{ switch (nb->state) { case X25_LINK_STATE_0:
skb_queue_tail(&nb->queue, skb);
nb->state = X25_LINK_STATE_1;
x25_establish_link(nb); break; case X25_LINK_STATE_1: case X25_LINK_STATE_2:
skb_queue_tail(&nb->queue, skb); break; case X25_LINK_STATE_3:
x25_send_frame(skb, nb); break;
}
}
/* * Called when the link layer has become established.
*/ void x25_link_established(struct x25_neigh *nb)
{ switch (nb->state) { case X25_LINK_STATE_0: case X25_LINK_STATE_1:
x25_transmit_restart_request(nb);
nb->state = X25_LINK_STATE_2;
x25_start_t20timer(nb); break;
}
}
/* * Called when the link layer has terminated, or an establishment * request has failed.
*/
/** * __x25_remove_neigh - remove neighbour from x25_neigh_list * @nb: - neigh to remove * * Remove neighbour from x25_neigh_list. If it was there. * Caller must hold x25_neigh_list_lock.
*/ staticvoid __x25_remove_neigh(struct x25_neigh *nb)
{ if (nb->node.next) {
list_del(&nb->node);
x25_neigh_put(nb);
}
}
/* * A device has been removed, remove its links.
*/ void x25_link_device_down(struct net_device *dev)
{ struct x25_neigh *nb; struct list_head *entry, *tmp;
write_lock_bh(&x25_neigh_list_lock);
list_for_each_safe(entry, tmp, &x25_neigh_list) {
nb = list_entry(entry, struct x25_neigh, node);
if (nb->dev == dev) {
__x25_remove_neigh(nb);
dev_put(dev);
}
}
write_unlock_bh(&x25_neigh_list_lock);
}
/* * Given a device, return the neighbour address.
*/ struct x25_neigh *x25_get_neigh(struct net_device *dev)
{ struct x25_neigh *nb, *use = NULL;
read_lock_bh(&x25_neigh_list_lock);
list_for_each_entry(nb, &x25_neigh_list, node) { if (nb->dev == dev) {
use = nb; break;
}
}
if (use)
x25_neigh_hold(use);
read_unlock_bh(&x25_neigh_list_lock); return use;
}
/* * Handle the ioctls that control the subscription functions.
*/ int x25_subscr_ioctl(unsignedint cmd, void __user *arg)
{ struct x25_subscrip_struct x25_subscr; struct x25_neigh *nb; struct net_device *dev; int rc = -EINVAL;
if (cmd != SIOCX25GSUBSCRIP && cmd != SIOCX25SSUBSCRIP) goto out;
rc = -EFAULT; if (copy_from_user(&x25_subscr, arg, sizeof(x25_subscr))) goto out;
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.