net/bluetooth/6lowpan.c
Source file repositories/reference/linux-study-clean/net/bluetooth/6lowpan.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/6lowpan.c- Extension
.c- Size
- 29768 bytes
- Lines
- 1360
- 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.
- 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/if_arp.hlinux/netdevice.hlinux/etherdevice.hlinux/module.hlinux/debugfs.hnet/ipv6.hnet/ip6_route.hnet/addrconf.hnet/netdev_lock.hnet/pkt_sched.hnet/bluetooth/bluetooth.hnet/bluetooth/hci_core.hnet/bluetooth/l2cap.hnet/6lowpan.h
Detected Declarations
struct skb_cbstruct lowpan_peerstruct lowpan_btle_devstruct set_enablefunction lowpan_btle_devfunction peer_addfunction peer_delfunction __peer_lookup_chanfunction list_for_each_entry_rcufunction __peer_lookup_connfunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction give_skb_to_upperfunction iphc_decompressfunction recv_pktfunction chan_recv_cbfunction setup_headerfunction header_createfunction send_pktfunction send_mcast_pktfunction list_for_each_entry_rcufunction list_for_each_entry_rcufunction bt_xmitfunction bt_dev_initfunction netdev_setupfunction ifupfunction ifdownfunction do_notify_peersfunction is_bt_6lowpanfunction setup_netdevfunction chan_ready_cbfunction unregister_devfunction delete_netdevfunction chan_close_cbfunction list_for_each_entry_rcufunction chan_state_change_cbfunction chan_suspend_cbfunction chan_resume_cbfunction chan_get_sndtimeo_cbfunction bt_6lowpan_connectfunction bt_6lowpan_disconnectfunction get_l2cap_connfunction disconnect_all_peersfunction list_for_each_entry_rcufunction do_enable_set
Annotated Snippet
static const struct net_device_ops netdev_ops = {
.ndo_init = bt_dev_init,
.ndo_start_xmit = bt_xmit,
};
static const struct header_ops header_ops = {
.create = header_create,
};
static void netdev_setup(struct net_device *dev)
{
dev->hard_header_len = 0;
dev->needed_tailroom = 0;
dev->flags = IFF_RUNNING | IFF_MULTICAST;
dev->watchdog_timeo = 0;
dev->tx_queue_len = DEFAULT_TX_QUEUE_LEN;
dev->netdev_ops = &netdev_ops;
dev->header_ops = &header_ops;
dev->needs_free_netdev = true;
}
static const struct device_type bt_type = {
.name = "bluetooth",
};
static void ifup(struct net_device *netdev)
{
int err;
rtnl_lock();
err = dev_open(netdev, NULL);
if (err < 0)
BT_INFO("iface %s cannot be opened (%d)", netdev->name, err);
rtnl_unlock();
}
static void ifdown(struct net_device *netdev)
{
rtnl_lock();
dev_close(netdev);
rtnl_unlock();
}
static void do_notify_peers(struct work_struct *work)
{
struct lowpan_btle_dev *dev = container_of(work, struct lowpan_btle_dev,
notify_peers.work);
netdev_notify_peers(dev->netdev); /* send neighbour adv at startup */
}
static bool is_bt_6lowpan(struct hci_conn *hcon)
{
if (hcon->type != LE_LINK)
return false;
if (!enable_6lowpan)
return false;
return true;
}
static struct l2cap_chan *chan_create(void)
{
struct l2cap_chan *chan;
chan = l2cap_chan_create();
if (!chan)
return NULL;
l2cap_chan_set_defaults(chan);
chan->chan_type = L2CAP_CHAN_CONN_ORIENTED;
chan->mode = L2CAP_MODE_LE_FLOWCTL;
chan->imtu = 1280;
return chan;
}
static struct l2cap_chan *add_peer_chan(struct l2cap_chan *chan,
struct lowpan_btle_dev *dev,
bool new_netdev)
{
struct lowpan_peer *peer;
peer = kzalloc_obj(*peer, GFP_ATOMIC);
if (!peer)
return NULL;
Annotation
- Immediate include surface: `linux/if_arp.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/module.h`, `linux/debugfs.h`, `net/ipv6.h`, `net/ip6_route.h`, `net/addrconf.h`.
- Detected declarations: `struct skb_cb`, `struct lowpan_peer`, `struct lowpan_btle_dev`, `struct set_enable`, `function lowpan_btle_dev`, `function peer_add`, `function peer_del`, `function __peer_lookup_chan`, `function list_for_each_entry_rcu`, `function __peer_lookup_conn`.
- 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.
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.