net/bluetooth/lib.c
Source file repositories/reference/linux-study-clean/net/bluetooth/lib.c
File Facts
- System
- Linux kernel
- Corpus path
net/bluetooth/lib.c- Extension
.c- Size
- 6587 bytes
- Lines
- 381
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hnet/bluetooth/bluetooth.h
Detected Declarations
function Copyrightfunction bt_to_errnofunction bt_statusfunction bt_infofunction bt_warnfunction bt_errfunction bt_dbg_setfunction bt_dbg_getfunction bt_dbgfunction bt_warn_ratelimitedfunction bt_err_ratelimitedexport baswapexport bt_to_errnoexport bt_statusexport bt_infoexport bt_warnexport bt_errexport bt_dbgexport bt_warn_ratelimitedexport bt_err_ratelimited
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
BlueZ - Bluetooth protocol stack for Linux
Copyright (C) 2000-2001 Qualcomm Incorporated
Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
SOFTWARE IS DISCLAIMED.
*/
/* Bluetooth kernel library. */
#define pr_fmt(fmt) "Bluetooth: " fmt
#include <linux/export.h>
#include <net/bluetooth/bluetooth.h>
/**
* baswap() - Swaps the order of a bd address
* @dst: Pointer to a bdaddr_t struct that will store the swapped
* bd address.
* @src: Pointer to the bdaddr_t struct to be swapped.
*
* This function reverses the byte order of a Bluetooth device
* address.
*/
void baswap(bdaddr_t *dst, const bdaddr_t *src)
{
const unsigned char *s = (const unsigned char *)src;
unsigned char *d = (unsigned char *)dst;
unsigned int i;
for (i = 0; i < 6; i++)
d[i] = s[5 - i];
}
EXPORT_SYMBOL(baswap);
/**
* bt_to_errno() - Bluetooth error codes to standard errno
* @code: Bluetooth error code to be converted
*
* This function takes a Bluetooth error code as input and converts
* it to an equivalent Unix/standard errno value.
*
* Return:
*
* If the bt error code is known, an equivalent Unix errno value
* is returned.
* If the given bt error code is not known, ENOSYS is returned.
*/
int bt_to_errno(__u16 code)
{
switch (code) {
case 0:
return 0;
case 0x01:
return EBADRQC;
case 0x02:
return ENOTCONN;
case 0x03:
return EIO;
case 0x04:
case 0x3c:
return EHOSTDOWN;
case 0x05:
return EACCES;
case 0x06:
return EBADE;
case 0x07:
return ENOMEM;
Annotation
- Immediate include surface: `linux/export.h`, `net/bluetooth/bluetooth.h`.
- Detected declarations: `function Copyright`, `function bt_to_errno`, `function bt_status`, `function bt_info`, `function bt_warn`, `function bt_err`, `function bt_dbg_set`, `function bt_dbg_get`, `function bt_dbg`, `function bt_warn_ratelimited`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.