lib/net_utils.c
Source file repositories/reference/linux-study-clean/lib/net_utils.c
File Facts
- System
- Linux kernel
- Corpus path
lib/net_utils.c- Extension
.c- Size
- 657 bytes
- Lines
- 28
- Domain
- Kernel Services
- Bucket
- lib
- Inferred role
- Kernel Services: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
Dependency Surface
linux/string.hlinux/if_ether.hlinux/ctype.hlinux/export.hlinux/hex.h
Detected Declarations
function mac_ptonexport mac_pton
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/string.h>
#include <linux/if_ether.h>
#include <linux/ctype.h>
#include <linux/export.h>
#include <linux/hex.h>
bool mac_pton(const char *s, u8 *mac)
{
int i;
if (strnlen(s, MAC_ADDR_STR_LEN) < MAC_ADDR_STR_LEN)
return false;
/* Don't dirty result unless string is valid MAC. */
for (i = 0; i < ETH_ALEN; i++) {
if (!isxdigit(s[i * 3]) || !isxdigit(s[i * 3 + 1]))
return false;
if (i != ETH_ALEN - 1 && s[i * 3 + 2] != ':')
return false;
}
for (i = 0; i < ETH_ALEN; i++) {
mac[i] = (hex_to_bin(s[i * 3]) << 4) | hex_to_bin(s[i * 3 + 1]);
}
return true;
}
EXPORT_SYMBOL(mac_pton);
Annotation
- Immediate include surface: `linux/string.h`, `linux/if_ether.h`, `linux/ctype.h`, `linux/export.h`, `linux/hex.h`.
- Detected declarations: `function mac_pton`, `export mac_pton`.
- Atlas domain: Kernel Services / lib.
- Implementation status: integration 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.