MINOR: tools: make str2sa_range() directly return the protocol

We'll need this so that it can return pointers to stacked protocol in
the future (for QUIC). In addition this removes a lot of tests for
protocol validity in the callers.

Some of them were checked further apart, or after a call to
str2listener() and they were simplified as well.

There's still a trick, we can fail to return a protocol in case the caller
accepts an fqdn for use later. This is what servers do and in this case it
is valid to return no protocol. A typical example is:

   server foo localhost:1111
This commit is contained in:
Willy Tarreau
2020-09-16 18:25:03 +02:00
parent 9b3178df23
commit 5fc9328aa2
10 changed files with 55 additions and 65 deletions

View File

@@ -241,10 +241,9 @@ static inline int is_idchar(char c)
* If <pfx> is non-null, it is used as a string prefix before any path-based
* address (typically the path to a unix socket).
*/
struct sockaddr_storage *str2sa_range(const char *str,
int *port, int *low, int *high, int *fd,
char **err, const char *pfx,
char **fqdn, unsigned int opts);
struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int *high, int *fd,
struct protocol **proto, char **err,
const char *pfx, char **fqdn, unsigned int opts);
/* converts <str> to a struct in_addr containing a network mask. It can be
* passed in dotted form (255.255.255.0) or in CIDR form (24). It returns 1