net/bluetooth/hidp/sock.c
Source file repositories/reference/linux-study-clean/net/bluetooth/hidp/sock.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/hidp/sock.c- Extension
.c- Size
- 6822 bytes
- Lines
- 310
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/compat.hlinux/export.hlinux/file.hhidp.h
Detected Declarations
struct compat_hidp_connadd_reqfunction hidp_sock_releasefunction do_hidp_sock_ioctlfunction hidp_sock_ioctlfunction hidp_sock_compat_ioctlfunction hidp_sock_createfunction hidp_init_socketsfunction hidp_cleanup_sockets
Annotated Snippet
static const struct proto_ops hidp_sock_ops = {
.family = PF_BLUETOOTH,
.owner = THIS_MODULE,
.release = hidp_sock_release,
.ioctl = hidp_sock_ioctl,
#ifdef CONFIG_COMPAT
.compat_ioctl = hidp_sock_compat_ioctl,
#endif
.bind = sock_no_bind,
.getname = sock_no_getname,
.sendmsg = sock_no_sendmsg,
.recvmsg = sock_no_recvmsg,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.connect = sock_no_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.mmap = sock_no_mmap
};
static struct proto hidp_proto = {
.name = "HIDP",
.owner = THIS_MODULE,
.obj_size = sizeof(struct bt_sock)
};
static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
struct sock *sk;
BT_DBG("sock %p", sock);
if (sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;
sk = bt_sock_alloc(net, sock, &hidp_proto, protocol, GFP_ATOMIC, kern);
if (!sk)
return -ENOMEM;
sock->ops = &hidp_sock_ops;
sock->state = SS_UNCONNECTED;
bt_sock_link(&hidp_sk_list, sk);
return 0;
}
static const struct net_proto_family hidp_sock_family_ops = {
.family = PF_BLUETOOTH,
.owner = THIS_MODULE,
.create = hidp_sock_create
};
int __init hidp_init_sockets(void)
{
int err;
err = proto_register(&hidp_proto, 0);
if (err < 0)
return err;
err = bt_sock_register(BTPROTO_HIDP, &hidp_sock_family_ops);
if (err < 0) {
BT_ERR("Can't register HIDP socket");
goto error;
}
err = bt_procfs_init(&init_net, "hidp", &hidp_sk_list, NULL);
if (err < 0) {
BT_ERR("Failed to create HIDP proc file");
bt_sock_unregister(BTPROTO_HIDP);
goto error;
}
BT_INFO("HIDP socket layer initialized");
return 0;
error:
proto_unregister(&hidp_proto);
return err;
}
void __exit hidp_cleanup_sockets(void)
{
bt_procfs_cleanup(&init_net, "hidp");
bt_sock_unregister(BTPROTO_HIDP);
proto_unregister(&hidp_proto);
}
Annotation
- Immediate include surface: `linux/compat.h`, `linux/export.h`, `linux/file.h`, `hidp.h`.
- Detected declarations: `struct compat_hidp_connadd_req`, `function hidp_sock_release`, `function do_hidp_sock_ioctl`, `function hidp_sock_ioctl`, `function hidp_sock_compat_ioctl`, `function hidp_sock_create`, `function hidp_init_sockets`, `function hidp_cleanup_sockets`.
- 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.
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.