net/mac80211/debugfs_key.c
Source file repositories/reference/linux-study-clean/net/mac80211/debugfs_key.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac80211/debugfs_key.c- Extension
.c- Size
- 11421 bytes
- Lines
- 423
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kobject.hlinux/slab.hieee80211_i.hkey.hdebugfs.hdebugfs_key.h
Detected Declarations
function key_algorithm_readfunction key_tx_spec_writefunction key_tx_spec_readfunction key_rx_spec_readfunction key_replays_readfunction key_icverrors_readfunction key_mic_failures_readfunction key_key_readfunction ieee80211_debugfs_key_addfunction ieee80211_debugfs_key_removefunction ieee80211_debugfs_key_update_defaultfunction ieee80211_debugfs_key_remove_mgmt_defaultfunction ieee80211_debugfs_key_remove_beacon_default
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2003-2005 Devicescape Software, Inc.
* Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
* Copyright 2007 Johannes Berg <johannes@sipsolutions.net>
* Copyright (C) 2015 Intel Deutschland GmbH
* Copyright (C) 2021-2023 Intel Corporation
*/
#include <linux/kobject.h>
#include <linux/slab.h>
#include "ieee80211_i.h"
#include "key.h"
#include "debugfs.h"
#include "debugfs_key.h"
#define KEY_READ(name, prop, format_string) \
static ssize_t key_##name##_read(struct file *file, \
char __user *userbuf, \
size_t count, loff_t *ppos) \
{ \
struct ieee80211_key *key = file->private_data; \
return mac80211_format_buffer(userbuf, count, ppos, \
format_string, key->prop); \
}
#define KEY_READ_X(name) KEY_READ(name, name, "0x%x\n")
#define KEY_OPS(name) \
static const struct debugfs_short_fops key_ ##name## _ops = { \
.read = key_##name##_read, \
.llseek = generic_file_llseek, \
}
#define KEY_OPS_W(name) \
static const struct debugfs_short_fops key_ ##name## _ops = { \
.read = key_##name##_read, \
.write = key_##name##_write, \
.llseek = generic_file_llseek, \
}
#define KEY_FILE(name, format) \
KEY_READ_##format(name) \
KEY_OPS(name)
#define KEY_CONF_READ(name, format_string) \
KEY_READ(conf_##name, conf.name, format_string)
#define KEY_CONF_READ_D(name) KEY_CONF_READ(name, "%d\n")
#define KEY_CONF_OPS(name) \
static const struct debugfs_short_fops key_ ##name## _ops = { \
.read = key_conf_##name##_read, \
.llseek = generic_file_llseek, \
}
#define KEY_CONF_FILE(name, format) \
KEY_CONF_READ_##format(name) \
KEY_CONF_OPS(name)
KEY_CONF_FILE(keylen, D);
KEY_CONF_FILE(keyidx, D);
KEY_CONF_FILE(hw_key_idx, D);
KEY_FILE(flags, X);
KEY_READ(ifindex, sdata->name, "%s\n");
KEY_OPS(ifindex);
static ssize_t key_algorithm_read(struct file *file,
char __user *userbuf,
size_t count, loff_t *ppos)
{
char buf[15];
struct ieee80211_key *key = file->private_data;
u32 c = key->conf.cipher;
sprintf(buf, "%.2x-%.2x-%.2x:%d\n",
c >> 24, (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
return simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
}
KEY_OPS(algorithm);
static ssize_t key_tx_spec_write(struct file *file, const char __user *userbuf,
size_t count, loff_t *ppos)
{
struct ieee80211_key *key = file->private_data;
u64 pn;
int ret;
switch (key->conf.cipher) {
case WLAN_CIPHER_SUITE_WEP40:
case WLAN_CIPHER_SUITE_WEP104:
return -EINVAL;
Annotation
- Immediate include surface: `linux/kobject.h`, `linux/slab.h`, `ieee80211_i.h`, `key.h`, `debugfs.h`, `debugfs_key.h`.
- Detected declarations: `function key_algorithm_read`, `function key_tx_spec_write`, `function key_tx_spec_read`, `function key_rx_spec_read`, `function key_replays_read`, `function key_icverrors_read`, `function key_mic_failures_read`, `function key_key_read`, `function ieee80211_debugfs_key_add`, `function ieee80211_debugfs_key_remove`.
- 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.