net/ieee802154/socket.c
Source file repositories/reference/linux-study-clean/net/ieee802154/socket.c
File Facts
- System
- Linux kernel
- Corpus path
net/ieee802154/socket.c- Extension
.c- Size
- 23813 bytes
- Lines
- 1144
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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 an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/net.hlinux/capability.hlinux/module.hlinux/if_arp.hlinux/if.hlinux/termios.hlinux/list.hlinux/slab.hlinux/socket.hnet/datalink.hnet/psnap.hnet/sock.hnet/tcp_states.hnet/route.hnet/af_ieee802154.hnet/ieee802154_netdev.h
Detected Declarations
struct dgram_sockfunction ieee802154_get_devfunction for_each_netdevfunction ieee802154_sock_releasefunction ieee802154_sock_sendmsgfunction ieee802154_sock_bindfunction ieee802154_sock_connectfunction ieee802154_dev_ioctlfunction ieee802154_sock_ioctlfunction raw_hashfunction raw_unhashfunction raw_closefunction raw_bindfunction raw_connectfunction raw_disconnectfunction raw_sendmsgfunction raw_recvmsgfunction raw_rcv_skbfunction ieee802154_raw_deliverfunction raw_getsockoptfunction raw_setsockoptfunction dgram_hashfunction dgram_unhashfunction dgram_initfunction dgram_closefunction dgram_bindfunction dgram_ioctlfunction dgram_connectfunction dgram_disconnectfunction dgram_sendmsgfunction dgram_recvmsgfunction dgram_rcv_skbfunction ieee802154_match_sockfunction ieee802154_dgram_deliverfunction dgram_getsockoptfunction dgram_setsockoptfunction ieee802154_sock_destructfunction ieee802154_createfunction ieee802154_rcvfunction af_ieee802154_initfunction af_ieee802154_removemodule init af_ieee802154_init
Annotated Snippet
static const struct proto_ops ieee802154_raw_ops = {
.family = PF_IEEE802154,
.owner = THIS_MODULE,
.release = ieee802154_sock_release,
.bind = ieee802154_sock_bind,
.connect = ieee802154_sock_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = sock_no_getname,
.poll = datagram_poll,
.ioctl = ieee802154_sock_ioctl,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
.sendmsg = ieee802154_sock_sendmsg,
.recvmsg = sock_common_recvmsg,
.mmap = sock_no_mmap,
};
/* DGRAM Sockets (802.15.4 dataframes) */
static HLIST_HEAD(dgram_head);
static DEFINE_RWLOCK(dgram_lock);
struct dgram_sock {
struct sock sk;
struct ieee802154_addr src_addr;
struct ieee802154_addr dst_addr;
unsigned int bound:1;
unsigned int connected:1;
unsigned int want_ack:1;
unsigned int want_lqi:1;
unsigned int secen:1;
unsigned int secen_override:1;
unsigned int seclevel:3;
unsigned int seclevel_override:1;
};
static inline struct dgram_sock *dgram_sk(const struct sock *sk)
{
return container_of(sk, struct dgram_sock, sk);
}
static int dgram_hash(struct sock *sk)
{
write_lock_bh(&dgram_lock);
sk_add_node(sk, &dgram_head);
write_unlock_bh(&dgram_lock);
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
return 0;
}
static void dgram_unhash(struct sock *sk)
{
write_lock_bh(&dgram_lock);
if (sk_del_node_init(sk))
sock_prot_inuse_add(sock_net(sk), sk->sk_prot, -1);
write_unlock_bh(&dgram_lock);
}
static int dgram_init(struct sock *sk)
{
struct dgram_sock *ro = dgram_sk(sk);
ro->want_ack = 1;
ro->want_lqi = 0;
return 0;
}
static void dgram_close(struct sock *sk, long timeout)
{
sk_common_release(sk);
}
static int dgram_bind(struct sock *sk, struct sockaddr_unsized *uaddr, int len)
{
struct sockaddr_ieee802154 *addr = (struct sockaddr_ieee802154 *)uaddr;
struct ieee802154_addr haddr;
struct dgram_sock *ro = dgram_sk(sk);
int err = -EINVAL;
struct net_device *dev;
lock_sock(sk);
ro->bound = 0;
Annotation
- Immediate include surface: `linux/net.h`, `linux/capability.h`, `linux/module.h`, `linux/if_arp.h`, `linux/if.h`, `linux/termios.h`, `linux/list.h`, `linux/slab.h`.
- Detected declarations: `struct dgram_sock`, `function ieee802154_get_dev`, `function for_each_netdev`, `function ieee802154_sock_release`, `function ieee802154_sock_sendmsg`, `function ieee802154_sock_bind`, `function ieee802154_sock_connect`, `function ieee802154_dev_ioctl`, `function ieee802154_sock_ioctl`, `function raw_hash`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.