keyutils

title: keyutils(7)

summary: in-kernel key management utilities

text:
# keyutils(7)

## NAME
keyutils - in-kernel key management utilities

## DESCRIPTION
The keyutils package is a library and a set of utilities for accessing the kernel keyrings facility.

A header file is supplied to provide the definitions and declarations required to access the library:

\#include <keyutils.h>

To link with the library, the following:

-lkeyutils

should be specified to the linker.

Three system calls are provided:

add_key(2)

Supply a new key to the kernel.

request_key(2)

Find an existing key for use, or, optionally, create one if one does not exist.

keyctl(2)

Control a key in various ways. The library provides a variety of wrappers around this system call and those should be used rather than calling it directly.

See the add_key(2), request_key(2), and keyctl(2) manual pages for more information.

The keyctl() wrappers are listed on the keyctl(3) manual page.

## UTILITIES
A program is provided to interact with the kernel facility by a number of subcommands, e.g.:

keyctl add user foo bar @s

See the keyctl(1) manual page for information on that.

The kernel has the ability to upcall to userspace to fabricate new keys. This can be triggered by request_key(), but userspace is better off using add_key() instead if it possibly can.

The upcalling mechanism is usually routed via the request-key(8) program. What this does with any particular key is configurable in:

/etc/request-key.conf

/etc/request-key.d/

See the request-key.conf(5) and the request-key(8) manual pages for more information.

## SEE ALSO
keyctl(1), keyctl(3), keyrings(7), persistent-keyring(7), process-keyring(7), session-keyring(7), thread-keyring(7), user-keyring(7), user-session-keyring(7), pam_keyinit(8)


kresd.systemd

package: knot-resolver

title: kresd.systemd(7)

text:
# kresd.systemd(7)

## NAME
kresd.systemd - managing Knot Resolver 5.7.0 through systemd.

## SYNOPSIS

```
kresd@.service
kresd.target
system-kresd.slice
```

## DESCRIPTION
This manual page describes how to manage kresd using systemd units.

QUICKSTART

```
systemctl start kresd@1 - single instance of kresd, responding on localhost
```

```

```

CONCURRENT DAEMONS

kresd daemon can be executed in multiple independent processes, which are managed with systemd via systemd templates (see systemd.unit(5)). Each systemd service instance of kresd (kresd@.service) represents a single, independent kresd process.

If you have more than one CPU core available, a single running kresd daemon will only be able to make use of one core at a time, leaving the other cores idle. If you want kresd to take advantage of all available cores, while sharing both cache and sockets, you should enable and start as many instances of the kresd@.service as you have cores. Typically, each instance is just named kresd@N.service, where N is a decimal number. For example, to enable and start 3 concurrent daemons:

```
systemctl enable --now kresd@1.service kresd@2.service kresd@3.service
```

```

```

The systemd-managed kresd service set is grouped in the system-kresd.slice slice. The slice includes all running daemons (instances of kresd@.service).

## EXAMPLES
To start a single kresd instance and enable it at boot:

```
systemctl enable --now kresd@1.service
```

```

```

To restart (or stop) all running instances, you can use a glob expression. Please note that glob can't be used to start or enable instances.

```
systemctl restart 'kresd@*'
```

```

```

Bash users can also use Brace Expansion to enable or start multiple instances, instead of listing them manually.

```
systemctl enable --now kresd@{1..4}.service
```

```

```

To start all enabled kresd daemons, you can also use the provided kresd.target:

```
systemctl start kresd.target
```

```

```

## SEE ALSO
kresd(8), systemd.unit(5), https://knot-resolver.readthedocs.io/en/v5.7.0/

## AUTHORS
kresd developers are mentioned in the AUTHORS file in the distribution.


hci

package: libbluez-devel

title: hci(7)

summary: Bluetooth HCI protocol

text:
# hci(7)

## NAME
hci - Bluetooth HCI protocol

## SYNOPSIS

```
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
hci_socket = socket(PF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI);
```

## DESCRIPTION
Bluetooth Host Controller Interface (HCI) is the standard protocol to communicate with Bluetooth adapters. HCI protocol provides a uniform command method for the Host to access Controller capabilities and to control connections to other Controllers.

## SOCKET ADDRESS

```
struct sockaddr_hci {

    sa_family_t    hci_family;

    unsigned short hci_dev;

    unsigned short hci_channel;
};
```

Possible values for hci_channel:

Define

Value

Description

HCI_CHANNEL_RAW

0x00

Raw channel - Used for raw HCI communication

HCI_CHANNEL_USER

0x01

User channel - Used for userspace HCI communication (disables kernel processing)

HCI_CHANNEL_MONITOR

0x02

Monitor channel - Used for monitoring HCI traffic (btmon(1))

HCI_CHANNEL_CONTROL

0x03

Control channel - Used to manage local adapters (bluetoothd(7))

HCI_CHANNEL_LOGGING

0x04

Logging channel - Used to inject logging messages (bluetoothd(7))

Example:

```
struct sockaddr_hci addr;
memset(&addr, 0, sizeof(addr));
addr.hci_family = AF_BLUETOOTH;
addr.hci_dev = HCI_DEV_NONE;
addr.hci_channel = HCI_CHANNEL_CONTROL;
```

## SOCKET OPTIONS
The socket options listed below can be set by using setsockopt(2) and read with getsockopt(2) with the socket level set to SOL_BLUETOOTH or SOL_HCI (HCI_FILTER).

### HCI_FILTER (since Linux 2.6)
Filter by HCI events, requires hci_channel to be set to HCI_CHANNEL_RAW, possible values:

```
struct hci_filter {

    uint32_t type_mask;

    uint32_t event_mask[2];

    uint16_t opcode;
};
```

Example:

```
struct hci_filter flt;
memset(&flt, 0, sizeof(flt));
flt.type_mask = 1 << BT_H4_EVT_PKT;
flt.event_mask[0] = 0xffffffff;
flt.event_mask[1] = 0xffffffff;
setsockopt(fd, SOL_HCI, HCI_FILTER, &flt, sizeof(flt));
```

### BT_SNDBUF (since Linux 5.16)
Set send buffer size, requires hci_channel to be set to HCI_CHANNEL_MONITOR, HCI_CHANNEL_CONTROL or HCI_CHANNEL_LOGGING.

Default value is 1028.

Example:

```
uint16_t mtu = UINT16_MAX;
int err;
err = setsockopt(fd, SOL_BLUETOOTH, BT_SNDMTU, &mtu, sizeof(mtu));
```

### BT_RCVBUF (since Linux 5.16)
Set receive buffer size, requires hci_channel to be set to HCI_CHANNEL_MONITOR, HCI_CHANNEL_CONTROL or HCI_CHANNEL_LOGGING.

Default value is 1028.

Example:

```
uint16_t mtu;
socklen_t len;
int err;
len = sizeof(mtu);
err = getsockopt(sock, SOL_BLUETOOTH, BT_RCVMTU, mtu, &len);
```

## RESOURCES
http://www.bluez.org

## REPORTING BUGS
linux-bluetooth@vger.kernel.org

## SEE ALSO
socket(7)

## COPYRIGHT
Free use of this software is granted under the terms of the GNU Lesser General Public Licenses (LGPL).


title: l2cap(7)

summary: L2CAP protocol

text:
# l2cap(7)

## NAME
l2cap - L2CAP protocol

## SYNOPSIS

```
#include <sys/socket.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/l2cap.h>
l2cap_socket = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
```

## DESCRIPTION
L2CAP is a protocol that provides an interface for higher-level protocols to send and receive data over a Bluetooth connection. L2CAP sits on top of the Bluetooth Host Controller Interface (HCI) and provides a set of channels that can be used by higher-level protocols to transmit data.

L2CAP provides a number of services to higher-level protocols, including segmentation and reassembly of large data packets and flow control to prevent overloading of the receiver. L2CAP also supports multiple channels per connection, allowing for concurrent data transmission using different protocols.

## SOCKET ADDRESS

```
struct sockaddr_l2 {

    sa_family_t     l2_family;

    unsigned short  l2_psm;

    bdaddr_t        l2_bdaddr;

    unsigned short  l2_cid;

    uint8_t         l2_bdaddr_type;
};
```

Example:

```
struct sockaddr_l2 addr;
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
bacpy(&addr.l2_bdaddr, bdaddr);
if (cid)

    addr.l2_cid = htobs(cid);
else

    addr.l2_psm = htobs(psm);
addr.l2_bdaddr_type = bdaddr_type;
```

## SOCKET OPTIONS
The socket options listed below can be set by using setsockopt(2) and read with getsockopt(2) with the socket level set to SOL_BLUETOOTH.

### BT_SECURITY (since Linux 2.6.30)
Channel security level, possible values:

Value

Security Level

Link Key Type

Encryption

BT_SECURITY_SDP

0 (SDP Only)

None

Not required

BT_SECURITY_LOW

1 (Low)

Unauthenticated

Not required

BT_SECURITY_MEDIUM

2 (Medium - default)

Unauthenticated

Desired

BT_SECURITY_HIGH

3 (High)

Authenticated

Required

BT_SECURITY_FIPS (since Linux 3.15)

4 (Secure Only)

Authenticated (P-256 based Secure Simple Pairing and Secure Authentication)

Required

Example:

```
int level = BT_SECURITY_HIGH;
int err = setsockopt(l2cap_socket, SOL_BLUETOOTH, BT_SECURITY, &level,

                     sizeof(level));
if (err == -1) {

    perror("setsockopt");

    return 1;
}
```

### BT_DEFER_SETUP (since Linux 2.6.30)
Channel defer connection setup, this control if the connection procedure needs to be authorized by userspace before responding which allows authorization at profile level, possible values:

Value

Description

Authorization

0

Disable (default)

Not required

1

Enable

Required

Example:

```
int defer_setup = 1;
int err = setsockopt(l2cap_socket, SOL_BLUETOOTH, BT_DEFER_SETUP,

                     &defer_setup, sizeof(defer_setup));
if (err == -1) {

    perror("setsockopt");

    return err;
}
err = listen(l2cap_socket, 5);
if (err) {

    perror("listen");

    return err;
}
struct sockaddr_l2 remote_addr = {0};
socklen_t addr_len = sizeof(remote_addr);
int new_socket = accept(l2cap_socket, (struct sockaddr*)&remote_addr,

                        &addr_len);
if (new_socket < 0) {

    perror("accept");

    return new_socket;
}
/* To complete the connection setup of new_socket read 1 byte */
char c;
struct pollfd pfd;
memset(&pfd, 0, sizeof(pfd));
pfd.fd = new_socket;
pfd.events = POLLOUT;
err = poll(&pfd, 1, 0);
if (err) {

    perror("poll");

    return err;
}
if (!(pfd.revents & POLLOUT)) {

    err = read(sk, &c, 1);

    if (err < 0) {

        perror("read");

        return err;

    }
}
```

### BT_FLUSHABLE (since Linux 2.6.39)
Channel flushable flag, this control if the channel data can be flushed or not, possible values:

Define

Value

Description

BT_FLUSHABLE_OFF

0x00 (default)

Do not flush data

BT_FLUSHABLE_ON

0x01

Flush data

### BT_POWER (since Linux 3.1)
Channel power policy, this control if the channel shall force exit of sniff mode or not, possible values:

Define

Value

Description

BT_POWER_FORCE_ACTIVE_OFF

0x00

Don't force exit of sniff mode

BT_POWER_FORCE_ACTIVE_ON

0x01 (default)

Force exit of sniff mode

### BT_CHANNEL_POLICY (since Linux 3.10)
High-speed (AMP) channel policy, possible values:

Define

Value

Description

BT_CHANNEL_POLICY_BREDR_ONLY

0 (default)

BR/EDR only

BT_CHANNEL_POLICY_BREDR_PREFERRED

1

BR/EDR Preferred

BT_CHANNEL_POLICY_BREDR_PREFERRED

2

AMP Preferred

### BT_PHY (since Linux 5.10)
Channel supported PHY(s), possible values:

Define

Value

Description

BT_PHY_BR_1M_1SLOT

BIT 0

BR 1Mbps 1SLOT

BT_PHY_BR_1M_3SLOT

BIT 1

BR 1Mbps 3SLOT

BT_PHY_BR_1M_5SLOT

BIT 2

BR 1Mbps 5SLOT

BT_PHY_BR_2M_1SLOT

BIT 3

EDR 2Mbps 1SLOT

BT_PHY_BR_2M_3SLOT

BIT 4

EDR 2Mbps 3SLOT

BT_PHY_BR_2M_5SLOT

BIT 5

EDR 2Mbps 5SLOT

BT_PHY_BR_3M_1SLOT

BIT 6

EDR 3Mbps 1SLOT

BT_PHY_BR_3M_3SLOT

BIT 7

EDR 3Mbps 3SLOT

BT_PHY_BR_3M_5SLOT

BIT 8

EDR 3Mbps 5SLOT

BT_PHY_LE_1M_TX

BIT 9

LE 1Mbps TX

BT_PHY_LE_1M_RX

BIT 10

LE 1Mbps RX

BT_PHY_LE_2M_TX

BIT 11

LE 2Mbps TX

BT_PHY_LE_2M_RX

BIT 12

LE 2Mbps RX

BT_PHY_LE_CODED_TX

BIT 13

LE Coded TX

BT_PHY_LE_CODED_RX

BIT 14

LE Coded RX

### BT_MODE (since Linux 5.10)
Channel Mode, possible values:

Define

Value

Description

Link

BT_MODE_BASIC

0x00 (default)

Basic mode

Any

BT_MODE_ERTM

0x01

Enhanced Retransmission mode

BR/EDR

BT_MODE_STREAM

0x02

Stream mode

BR/EDR

BT_MODE_LE_FLOWCTL

0x03

Credit based flow control mode

LE

BT_MODE_EXT_FLOWCTL

0x04

Extended Credit based flow control mode

Any

## RESOURCES
http://www.bluez.org

## REPORTING BUGS
linux-bluetooth@vger.kernel.org

## SEE ALSO
socket(7), l2test(1)

## COPYRIGHT
Free use of this software is granted under the terms of the GNU Lesser General Public Licenses (LGPL).