include/linux/ip.h
Source file repositories/reference/linux-study-clean/include/linux/ip.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/ip.h- Extension
.h- Size
- 1593 bytes
- Lines
- 60
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/skbuff.huapi/linux/ip.h
Detected Declarations
function ip_transport_lenfunction iph_totlenfunction skb_ip_totlenfunction iph_set_totlen
Annotated Snippet
#ifndef _LINUX_IP_H
#define _LINUX_IP_H
#include <linux/skbuff.h>
#include <uapi/linux/ip.h>
static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
{
return (struct iphdr *)skb_network_header(skb);
}
static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
{
return (struct iphdr *)skb_inner_network_header(skb);
}
static inline struct iphdr *ipip_hdr(const struct sk_buff *skb)
{
return (struct iphdr *)skb_transport_header(skb);
}
static inline unsigned int ip_transport_len(const struct sk_buff *skb)
{
return ntohs(ip_hdr(skb)->tot_len) - skb_network_header_len(skb);
}
static inline unsigned int iph_totlen(const struct sk_buff *skb, const struct iphdr *iph)
{
u32 len = ntohs(iph->tot_len);
return (len || !skb_is_gso(skb) || !skb_is_gso_tcp(skb)) ?
len : skb->len - skb_network_offset(skb);
}
static inline unsigned int skb_ip_totlen(const struct sk_buff *skb)
{
return iph_totlen(skb, ip_hdr(skb));
}
/* IPv4 datagram length is stored into 16bit field (tot_len) */
#define IP_MAX_MTU 0xFFFFU
static inline void iph_set_totlen(struct iphdr *iph, unsigned int len)
{
iph->tot_len = len <= IP_MAX_MTU ? htons(len) : 0;
}
#endif /* _LINUX_IP_H */
Annotation
- Immediate include surface: `linux/skbuff.h`, `uapi/linux/ip.h`.
- Detected declarations: `function ip_transport_len`, `function iph_totlen`, `function skb_ip_totlen`, `function iph_set_totlen`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.