Skip to content
Snippets Groups Projects
Unverified Commit a3a95960 authored by Henri Nurmi's avatar Henri Nurmi Committed by GitHub
Browse files

wasi-sockets: Add services database and implement getservbyname/getservbyport functions (#532)

This is a follow-up PR for #524 by implementing the following features:

- Embeds a minimal network services database with 17 common protocols,
suggested by @badeend. The database array is a weak symbol allowing
applications to override the default database at link time.
- Updates `getaddrinfo` to resolve named services in the address info.
For example `getaddrinfo("google.com", "https", NULL, &res);`
- Implements the `getservbyname` and `getservbyport` functions. These
functions are implemented using a static variable (`global_serv`), which
holds the returned service entry. This approach is acceptable because
these functions [are defined as not being
thread-safe](https://man.archlinux.org/man/getservbyname.3.en).

~~Additionally, this PR introduces an optional, more comprehensive
services database (`sockets_full_services_db.c`), based on Debian
Bookworm's `/etc/services` file (320 entries). To use this database,
link with the `-lc-full-services-db` flag.~~
parent 48eb92c1
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment