net/x25/x25_subr.c
Source file repositories/reference/linux-study-clean/net/x25/x25_subr.c
File Facts
- System
- Linux kernel
- Corpus path
net/x25/x25_subr.c- Extension
.c- Size
- 9442 bytes
- Lines
- 386
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/slab.hlinux/kernel.hlinux/string.hlinux/skbuff.hnet/sock.hnet/tcp_states.hnet/x25.h
Detected Declarations
function x25_clear_queuesfunction x25_frames_ackedfunction x25_requeue_framesfunction x25_validate_nrfunction x25_write_internalfunction x25_decodefunction x25_disconnectfunction x25_check_rbuf
Annotated Snippet
while (skb_peek(&x25->ack_queue) && x25->va != nr) {
skb = skb_dequeue(&x25->ack_queue);
kfree_skb(skb);
x25->va = (x25->va + 1) % modulus;
}
}
void x25_requeue_frames(struct sock *sk)
{
struct sk_buff *skb, *skb_prev = NULL;
/*
* Requeue all the un-ack-ed frames on the output queue to be picked
* up by x25_kick. This arrangement handles the possibility of an empty
* output queue.
*/
while ((skb = skb_dequeue(&x25_sk(sk)->ack_queue)) != NULL) {
if (!skb_prev)
skb_queue_head(&sk->sk_write_queue, skb);
else
skb_append(skb_prev, skb, &sk->sk_write_queue);
skb_prev = skb;
}
}
/*
* Validate that the value of nr is between va and vs. Return true or
* false for testing.
*/
int x25_validate_nr(struct sock *sk, unsigned short nr)
{
struct x25_sock *x25 = x25_sk(sk);
unsigned short vc = x25->va;
int modulus = x25->neighbour->extended ? X25_EMODULUS : X25_SMODULUS;
while (vc != x25->vs) {
if (nr == vc)
return 1;
vc = (vc + 1) % modulus;
}
return nr == x25->vs ? 1 : 0;
}
/*
* This routine is called when the packet layer internally generates a
* control frame.
*/
void x25_write_internal(struct sock *sk, int frametype)
{
struct x25_sock *x25 = x25_sk(sk);
struct sk_buff *skb;
unsigned char *dptr;
unsigned char facilities[X25_MAX_FAC_LEN];
unsigned char addresses[1 + X25_ADDR_LEN];
unsigned char lci1, lci2;
/*
* Default safe frame size.
*/
int len = X25_MAX_L2_LEN + X25_EXT_MIN_LEN;
/*
* Adjust frame size.
*/
switch (frametype) {
case X25_CALL_REQUEST:
len += 1 + X25_ADDR_LEN + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN;
break;
case X25_CALL_ACCEPTED: /* fast sel with no restr on resp */
if (x25->facilities.reverse & 0x80) {
len += 1 + X25_MAX_FAC_LEN + X25_MAX_CUD_LEN;
} else {
len += 1 + X25_MAX_FAC_LEN;
}
break;
case X25_CLEAR_REQUEST:
case X25_RESET_REQUEST:
len += 2;
break;
case X25_RR:
case X25_RNR:
case X25_REJ:
case X25_CLEAR_CONFIRMATION:
case X25_INTERRUPT_CONFIRMATION:
case X25_RESET_CONFIRMATION:
break;
default:
pr_err("invalid frame type %02X\n", frametype);
return;
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kernel.h`, `linux/string.h`, `linux/skbuff.h`, `net/sock.h`, `net/tcp_states.h`, `net/x25.h`.
- Detected declarations: `function x25_clear_queues`, `function x25_frames_acked`, `function x25_requeue_frames`, `function x25_validate_nr`, `function x25_write_internal`, `function x25_decode`, `function x25_disconnect`, `function x25_check_rbuf`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.