BIO_PARSE_HOSTSERV(3ossl)
okay bestie, welcome to BIO_PARSE_HOSTSERV(3ossl) β the OpenSSL manual page for the little parser that handles host/service strings, and yes itβs giving useful π
πΈ NAME πΈ
BIO_hostserv_priorities, BIO_parse_hostserv β utility routines to parse a standard host and service string. π
β¨ SYNOPSIS β¨
#include <openssl/bio.h>
enum BIO_hostserv_priorities {
BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV
};
int BIO_parse_hostserv(const char *hostserv, char **host, char **service,
enum BIO_hostserv_priorities hostserv_prio);
π DESCRIPTION π
So BIO_parse_hostserv() takes the info in hostserv, makes strings for the hostname and the service name, and hands them back through host and service. Those strings need to be freed after theyβre used β donβt leave them lingering, bestie. π«Ά
When things are ambiguous, hostserv_prio is the deciding vibe: it helps determine if hostserv shall be interpreted primarily as a hostname or as a service name.
The syntax that BIO_parse_hostserv() recognises is:
host + ':' + service
host + ':' + '*'
host + ':'
':' + service
'*' + ':' + service
host
service
The host part can be a name or an IP address. If itβs an IPv6 address, it MUST be enclosed in brackets, such as '[::1]'. No cap, brackets are mandatory there.
The service part can be a service name or its port number. A service name will be mapped to a port number using the system function getservbyname().
The returned values depend on the given hostserv string and hostserv_prio, like this:
host + ':' + service => *host = "host", *service = "service"
host + ':' + '*' => *host = "host", *service = NULL
host + ':' => *host = "host", *service = NULL
':' + service => *host = NULL, *service = "service"
'*' + ':' + service => *host = NULL, *service = "service"
In case no ':' is present in the string, the result depends on hostserv_prio, as follows:
when hostserv_prio == BIO_PARSE_PRIO_HOST
host => *host = "host", *service untouched
when hostserv_prio == BIO_PARSE_PRIO_SERV
service => *host untouched, *service = "service"
π₯ RETURN VALUES π₯
BIO_parse_hostserv() returns 1 on success or 0 on error. Simple slay. β
π¦ SEE ALSO π¦
π COPYRIGHT π
Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.
mwah π this page is from OpenSSL 3.5.6, dated 2026-04-07 β go forth and parse those host/service strings, bestie ππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms