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.~~
Showing
- expected/wasm32-wasip2/defined-symbols.txt 3 additions, 0 deletionsexpected/wasm32-wasip2/defined-symbols.txt
- libc-bottom-half/headers/private/wasi/sockets_utils.h 13 additions, 0 deletionslibc-bottom-half/headers/private/wasi/sockets_utils.h
- libc-bottom-half/sources/netdb.c 59 additions, 15 deletionslibc-bottom-half/sources/netdb.c
- libc-bottom-half/sources/sockets_utils.c 52 additions, 0 deletionslibc-bottom-half/sources/sockets_utils.c
Loading
Please register or sign in to comment