net/lapb/lapb_subr.c
Source file repositories/reference/linux-study-clean/net/lapb/lapb_subr.c
File Facts
- System
- Linux kernel
- Corpus path
net/lapb/lapb_subr.c- Extension
.c- Size
- 7487 bytes
- Lines
- 300
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/errno.hlinux/types.hlinux/socket.hlinux/in.hlinux/kernel.hlinux/timer.hlinux/string.hlinux/sockios.hlinux/net.hlinux/inet.hlinux/skbuff.hlinux/slab.hnet/sock.hlinux/uaccess.hlinux/fcntl.hlinux/mm.hlinux/interrupt.hnet/lapb.h
Detected Declarations
function lapb_clear_queuesfunction lapb_frames_ackedfunction lapb_requeue_framesfunction lapb_validate_nrfunction lapb_decodefunction machinefunction lapb_transmit_frmr
Annotated Snippet
while (skb_peek(&lapb->ack_queue) && lapb->va != nr) {
skb = skb_dequeue(&lapb->ack_queue);
kfree_skb(skb);
lapb->va = (lapb->va + 1) % modulus;
}
}
void lapb_requeue_frames(struct lapb_cb *lapb)
{
struct sk_buff *skb, *skb_prev = NULL;
/*
* Requeue all the un-ack-ed frames on the output queue to be picked
* up by lapb_kick called from the timer. This arrangement handles the
* possibility of an empty output queue.
*/
while ((skb = skb_dequeue(&lapb->ack_queue)) != NULL) {
if (!skb_prev)
skb_queue_head(&lapb->write_queue, skb);
else
skb_append(skb_prev, skb, &lapb->write_queue);
skb_prev = skb;
}
}
/*
* Validate that the value of nr is between va and vs. Return true or
* false for testing.
*/
int lapb_validate_nr(struct lapb_cb *lapb, unsigned short nr)
{
unsigned short vc = lapb->va;
int modulus;
modulus = (lapb->mode & LAPB_EXTENDED) ? LAPB_EMODULUS : LAPB_SMODULUS;
while (vc != lapb->vs) {
if (nr == vc)
return 1;
vc = (vc + 1) % modulus;
}
return nr == lapb->vs;
}
/*
* This routine is the centralised routine for parsing the control
* information for the different frame formats.
*/
int lapb_decode(struct lapb_cb *lapb, struct sk_buff *skb,
struct lapb_frame *frame)
{
frame->type = LAPB_ILLEGAL;
lapb_dbg(2, "(%p) S%d RX %3ph\n", lapb->dev, lapb->state, skb->data);
/* We always need to look at 2 bytes, sometimes we need
* to look at 3 and those cases are handled below.
*/
if (!pskb_may_pull(skb, 2))
return -1;
if (lapb->mode & LAPB_MLP) {
if (lapb->mode & LAPB_DCE) {
if (skb->data[0] == LAPB_ADDR_D)
frame->cr = LAPB_COMMAND;
if (skb->data[0] == LAPB_ADDR_C)
frame->cr = LAPB_RESPONSE;
} else {
if (skb->data[0] == LAPB_ADDR_C)
frame->cr = LAPB_COMMAND;
if (skb->data[0] == LAPB_ADDR_D)
frame->cr = LAPB_RESPONSE;
}
} else {
if (lapb->mode & LAPB_DCE) {
if (skb->data[0] == LAPB_ADDR_B)
frame->cr = LAPB_COMMAND;
if (skb->data[0] == LAPB_ADDR_A)
frame->cr = LAPB_RESPONSE;
} else {
if (skb->data[0] == LAPB_ADDR_A)
frame->cr = LAPB_COMMAND;
if (skb->data[0] == LAPB_ADDR_B)
frame->cr = LAPB_RESPONSE;
}
}
skb_pull(skb, 1);
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/in.h`, `linux/kernel.h`, `linux/timer.h`, `linux/string.h`, `linux/sockios.h`.
- Detected declarations: `function lapb_clear_queues`, `function lapb_frames_acked`, `function lapb_requeue_frames`, `function lapb_validate_nr`, `function lapb_decode`, `function machine`, `function lapb_transmit_frmr`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.