FIDO_DEV_INFO_MANIFEST(3)

πŸ“¦
version 1.17.0 Β· 2 versions
  • 1.17.0 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 1.10.0 Β· ubuntu jammy
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian bookworm, debian trixie, fedora 43, fedora 44, nixos 26.05, nixpkgs unstable, opensuse-leap 16.0, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– FIDO_DEV_INFO_MANIFEST β€” the FIDO2 device discovery functions, bestie edition πŸ’–

okay so this is the FIDO_DEV_INFO_MANIFEST(3) page from the Library Functions Manual, and it's literally all about finding your FIDO2 devices and poking at their little info cards. sit down, grab a boba, we're doing this πŸ§‹βœ¨


✨ NAME ✨

fido_dev_info_manifest, fido_dev_info_new, fido_dev_info_free, fido_dev_info_ptr, fido_dev_info_path, fido_dev_info_product, fido_dev_info_vendor, fido_dev_info_manufacturer_string, fido_dev_info_product_string, fido_dev_info_set β€” FIDO2 device discovery functions πŸ¦‹

like. the whole friend group. all ten of them. slay.


🌸 SYNOPSIS 🌸

#include <fido.h>

int
fido_dev_info_manifest(fido_dev_info_t *devlist, size_t ilen,
    size_t *olen);

fido_dev_info_t *
fido_dev_info_new(size_t n);

void
fido_dev_info_free(fido_dev_info_t **devlist_p, size_t n);

const fido_dev_info_t *
fido_dev_info_ptr(const fido_dev_info_t *devlist, size_t i);

const char *
fido_dev_info_path(const fido_dev_info_t *di);

int16_t
fido_dev_info_product(const fido_dev_info_t *di);

int16_t
fido_dev_info_vendor(const fido_dev_info_t *di);

const char *
fido_dev_info_manufacturer_string(const fido_dev_info_t *di);

const char *
fido_dev_info_product_string(const fido_dev_info_t *di);

int
fido_dev_info_set(fido_dev_info_t *devlist, size_t i, const char *path,
    const char *manufacturer, const char *product,
    const fido_dev_io_t *io, const fido_dev_transport_t *transport);

πŸ‘‘ DESCRIPTION πŸ‘‘

πŸ” finding devices: fido_dev_info_manifest()

okay so fido_dev_info_manifest() fills up devlist with up to ilen FIDO2 devices that the underlying operating system managed to find. and rn? only USB HID devices are supported. that's it. that's the roster. πŸ’…

the number of discovered devices comes back in olen, and olen has to be an addressable pointer. no cap.

πŸŽ€ making a list: fido_dev_info_new()

fido_dev_info_new() returns a pointer to a freshly allocated, empty device list with n available slots. and if memory isn't available? it returns NULL. tragic. 😭

🧹 cleaning up: fido_dev_info_free()

fido_dev_info_free() releases the memory backing *devlist_p, where *devlist_p must have been previously allocated by fido_dev_info_new(). you also gotta hand over the number n of allocated slots. on return, *devlist_p gets set to NULL.

and here's the cute part: either devlist_p or *devlist_p may be NULL, and in that case fido_dev_info_free() is a NOP. it just... doesn't do anything. iconic, honestly. 🫢

πŸ¦‹ grabbing a slot: fido_dev_info_ptr()

fido_dev_info_ptr() returns a pointer to slot number i of devlist. and it is the caller's responsibility to ensure that i is bounded. that's on you, bestie. also pls note: the first slot has index 0. zero-indexed, as the universe intended. ✨

πŸ“ the getters πŸ“

  • fido_dev_info_path() returns the filesystem path or subsystem-specific identification string of di.
  • fido_dev_info_product() returns the product ID of di.
  • fido_dev_info_vendor() returns the vendor ID of di.
  • fido_dev_info_manufacturer_string() returns the manufacturer string of di. if di does not have an associated manufacturer string, fido_dev_info_manufacturer_string() returns an empty string. (an empty string, not a sad little NULL. she's polite.)
  • fido_dev_info_product_string() returns the product string of di. and same vibe β€” if di does not have an associated product string, fido_dev_info_product_string() returns an empty string.

πŸ’« the example

an example of how to use the functions described in this document can be found in the examples/manifest.c file shipped with libfido2. go read it, it's giving tutorial energy. πŸ“–

🧚 setting it up yourself: fido_dev_info_set()

fido_dev_info_set() initializes an entry in a device list allocated by fido_dev_info_new() with the specified path, manufacturer, and product strings, and with the specified I/O handlers and, optionally, transport functions, as described in fido_dev_set_io_functions(3).

the io argument must be specified; the transport argument may be NULL.

the path, I/O handlers, and transport functions will be used automatically by fido_dev_new_with_info(3) and fido_dev_open_with_info(3). so an application can use this, for example, to substitute mock FIDO2 devices in testing for the real ones that fido_dev_info_manifest() would discover. fake devices in the group chat. pretending. it's a bit of a moment. πŸ™ˆ


⭐ RETURN VALUES ⭐

fido_dev_info_manifest() always returns FIDO_OK. and if a discovery error occurs? the olen pointer is set to 0. that's your little signal. 🚨

fido_dev_info_set() returns FIDO_OK on success. on error, a different error code defined in <fido/err.h> is returned. check the header, bestie.

and the pointers returned by fido_dev_info_ptr(), fido_dev_info_path(), fido_dev_info_manufacturer_string(), and fido_dev_info_product_string() are guaranteed to exist until fido_dev_info_free() is called on the corresponding device list. so like, don't free the list and then go poking at the pointers. that would be a vibe check you fail. πŸ’€


friendly lil reminder: keep that i bounded, keep your olen addressable, and free your lists. main character energy requires memory hygiene. πŸ’œ

and that's the whole page, bestie!! this one came from the Debian build, dated March 30, 2022 πŸŽ€ go manifest some devices, you're gonna do great. mwah. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from