* supported protocol types, and ctrl_type of either SOCK_STREAM or SOCK_DGRAM
* depending on the requested values, or NULL if not found.
*/
-static inline struct protocol *protocol_lookup(int family, enum proto_type proto_type, int ctrl_dgram)
+static inline struct protocol *protocol_lookup(int family, enum proto_type proto_type, int alt)
{
if (family >= 0 && family < AF_CUST_MAX)
- return __protocol_by_family[family][proto_type][!!ctrl_dgram];
+ return __protocol_by_family[family][proto_type][!!alt];
return NULL;
}
*/
struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int *high, int *fd,
struct protocol **proto, struct net_addr_type *sa_type,
- char **err, const char *pfx, char **fqdn, unsigned int opts);
+ char **err, const char *pfx, char **fqdn, int *alt, unsigned int opts);
/* converts <addr> and <port> into a string representation of the address and port. This is sort
err_code |= ERR_WARN;
sk = str2sa_range(args[1], NULL, &port1, &port2, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_STREAM | PA_O_XPRT | PA_O_CONNECT);
if (!sk) {
ha_alert("parsing [%s:%d] : '%s' : %s\n", file, linenum, args[0], errmsg);
curproxy->conn_src.iface_len = 0;
sk = str2sa_range(args[1], NULL, &port1, &port2, NULL, NULL, NULL,
- &errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
+ &errmsg, NULL, NULL, NULL,
+ PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
ha_alert("parsing [%s:%d] : '%s %s' : %s\n",
file, linenum, args[0], args[1], errmsg);
struct sockaddr_storage *sk;
sk = str2sa_range(args[cur_arg + 1], NULL, &port1, &port2, NULL, NULL, NULL,
- &errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
+ &errmsg, NULL, NULL, NULL,
+ PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
ha_alert("parsing [%s:%d] : '%s %s' : %s\n",
file, linenum, args[cur_arg], args[cur_arg+1], errmsg);
ss2 = str2sa_range(str, NULL, &port, &end, &fd, &proto, NULL, err,
(curproxy == global.cli_fe || curproxy == mworker_proxy) ? NULL : global.unix_bind.prefix,
- NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
+ NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
PA_O_SOCKET_FD | PA_O_STREAM | PA_O_XPRT);
if (!ss2)
goto fail;
ss2 = str2sa_range(str, NULL, &port, &end, &fd, &proto, NULL, err,
curproxy == global.cli_fe ? NULL : global.unix_bind.prefix,
- NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
+ NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_PORT_RANGE |
PA_O_SOCKET_FD | PA_O_DGRAM | PA_O_XPRT);
if (!ss2)
goto fail;
newmailer->id = strdup(args[1]);
sk = str2sa_range(args[2], NULL, &port1, &port2, NULL, &proto, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_STREAM | PA_O_XPRT | PA_O_CONNECT);
if (!sk) {
ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
goto error;
}
- sk = str2sa_range(args[*cur_arg+1], NULL, &port1, &port2, NULL, NULL, NULL, errmsg, NULL, NULL,
+ sk = str2sa_range(args[*cur_arg+1], NULL, &port1, &port2, NULL, NULL, NULL, errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
memprintf(errmsg, "'%s' : %s", args[*cur_arg], *errmsg);
memprintf(&msg, "sockpair@%d", child->ipc_fd[0]);
if ((sk = str2sa_range(msg, &port, &port1, &port2, NULL, &proto, NULL,
- &errmsg, NULL, NULL, PA_O_STREAM)) == 0) {
+ &errmsg, NULL, NULL, NULL, PA_O_STREAM)) == 0) {
goto error;
}
ha_free(&msg);
csk_ctx->srv = socket_tcp;
/* Parse ip address. */
- addr = str2sa_range(ip, NULL, &low, &high, NULL, NULL, NULL, NULL, NULL, NULL, PA_O_PORT_OK | PA_O_STREAM);
+ addr = str2sa_range(ip, NULL, &low, &high, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, PA_O_PORT_OK | PA_O_STREAM);
if (!addr) {
xref_unlock(&socket->xref, peer);
WILL_LJMP(luaL_error(L, "connect: cannot parse destination address '%s'", ip));
sockaddr_free(&hc->dst);
/* 'sk' is statically allocated (no need to be freed). */
sk = str2sa_range(dst, NULL, NULL, NULL, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_PORT_OK | PA_O_STREAM | PA_O_XPRT | PA_O_CONNECT);
if (!sk) {
ha_alert("httpclient: Failed to parse destination address in %s\n", errmsg);
/* parse the target address */
sk = str2sa_range(raw, NULL, &port1, &port2, &fd, &proto, NULL,
- err, NULL, NULL,
+ err, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_RAW_FD | PA_O_DGRAM | PA_O_STREAM | PA_O_DEFAULT_DGRAM);
if (!sk)
goto error;
}
sk = str2sa_range(args[2], NULL, &port1, &port2, NULL, &proto, NULL,
- &errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_DGRAM | PA_O_STREAM | PA_O_DEFAULT_DGRAM);
+ &errmsg, NULL, NULL, NULL,
+ PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_DGRAM | PA_O_STREAM | PA_O_DEFAULT_DGRAM);
if (!sk) {
ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
err_code |= ERR_ALERT | ERR_FATAL;
/* 'sk' is statically allocated (no need to be freed). */
sk = str2sa_range(args[*cur_arg + 1], NULL, &port_low, &port_high, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_RANGE | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
memprintf(err, "'%s %s' : %s\n", args[*cur_arg], args[*cur_arg + 1], errmsg);
/* 'sk' is statically allocated (no need to be freed). */
sk = str2sa_range(args[*cur_arg + 1], NULL, &port1, &port2, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
ha_alert("'%s %s' : %s\n", args[*cur_arg], args[*cur_arg + 1], errmsg);
/* 'sk' is statically allocated (no need to be freed). */
sk = str2sa_range(args[*cur_arg + 1], NULL, &port_low, &port_high, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_RESOLVE | PA_O_PORT_OK | PA_O_PORT_MAND | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
memprintf(err, "'%s %s' : %s\n", args[*cur_arg], args[*cur_arg + 1], errmsg);
goto skip_addr;
sk = str2sa_range(args[*cur_arg], &port, &port1, &port2, NULL, NULL, &newsrv->addr_type,
- &errmsg, NULL, &fqdn,
+ &errmsg, NULL, &fqdn, NULL,
(parse_flags & SRV_PARSE_INITIAL_RESOLVE ? PA_O_RESOLVE : 0) | PA_O_PORT_OK |
(parse_flags & SRV_PARSE_IN_PEER_SECTION ? PA_O_PORT_MAND : PA_O_PORT_OFS) |
PA_O_STREAM | PA_O_DGRAM | PA_O_XPRT);
sockaddr_free(&ocsp_update_dst);
/* 'sk' is statically allocated (no need to be freed). */
sk = str2sa_range(args[1], NULL, NULL, NULL, NULL, NULL, NULL,
- &errmsg, NULL, NULL,
+ &errmsg, NULL, NULL, NULL,
PA_O_PORT_OK | PA_O_STREAM | PA_O_XPRT | PA_O_CONNECT);
if (!sk) {
ha_alert("ocsp-update: Failed to parse destination address in %s\n", errmsg);
}
sk = str2sa_range(args[cur_arg+1], NULL, &port1, &port2, NULL, NULL, NULL,
- errmsg, NULL, NULL, PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
+ errmsg, NULL, NULL, NULL,
+ PA_O_RESOLVE | PA_O_PORT_OK | PA_O_STREAM | PA_O_CONNECT);
if (!sk) {
memprintf(errmsg, "'%s' : %s.", args[cur_arg], *errmsg);
goto error;
*/
struct sockaddr_storage *str2sa_range(const char *str, int *port, int *low, int *high, int *fd,
struct protocol **proto, struct net_addr_type *sa_type,
- char **err, const char *pfx, char **fqdn, unsigned int opts)
+ char **err, const char *pfx, char **fqdn, int *alt, unsigned int opts)
{
static THREAD_LOCAL struct sockaddr_storage ss;
struct sockaddr_storage *ret = NULL;
int new_fd = -1;
enum proto_type proto_type = 0; // to shut gcc warning
int ctrl_type = 0; // to shut gcc warning
+ int alt_proto = 0;
portl = porth = porta = 0;
if (fqdn)
((opts & (PA_O_STREAM|PA_O_DGRAM)) == (PA_O_DGRAM|PA_O_STREAM) && (opts & PA_O_DEFAULT_DGRAM))) {
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
} else {
proto_type = PROTO_TYPE_STREAM;
ctrl_type = SOCK_STREAM;
str2 += 6;
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
}
else if (strncmp(str2, "quic+", 5) == 0) {
str2 += 5;
ss.ss_family = AF_UNIX;
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
}
else if (strncmp(str2, "uxst@", 5) == 0) {
str2 += 5;
ss.ss_family = AF_INET;
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
}
else if (strncmp(str2, "tcp6@", 5) == 0) {
str2 += 5;
ss.ss_family = AF_INET6;
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
}
else if (strncmp(str2, "tcp@", 4) == 0) {
str2 += 4;
ss.ss_family = AF_UNSPEC;
proto_type = PROTO_TYPE_DGRAM;
ctrl_type = SOCK_DGRAM;
+ alt_proto = 1;
}
else if (strncmp(str2, "quic4@", 6) == 0) {
str2 += 6;
*/
new_proto = protocol_lookup(ss.ss_family,
proto_type,
- ctrl_type == SOCK_DGRAM);
+ alt_proto);
if (!new_proto && (!fqdn || !*fqdn) && (ss.ss_family != AF_CUST_EXISTING_FD)) {
memprintf(err, "unsupported %s protocol for %s family %d address '%s'%s",
sa_type->proto_type = proto_type;
sa_type->xprt_type = (ctrl_type == SOCK_DGRAM) ? PROTO_TYPE_DGRAM : PROTO_TYPE_STREAM;
}
+ if (alt)
+ *alt = alt_proto;
free(back);
return ret;
}
sa = &ss;
}
else {
- sa = str2sa_range(ipstring, NULL, NULL, NULL, NULL, NULL, NULL, &errmsg, NULL, NULL,
+ sa = str2sa_range(ipstring, NULL, NULL, NULL, NULL, NULL, NULL, &errmsg, NULL, NULL, NULL,
PA_O_PORT_OK | PA_O_STREAM | PA_O_DGRAM | PA_O_XPRT | PA_O_CONNECT |
PA_O_PORT_RANGE | PA_O_PORT_OFS | PA_O_RESOLVE);
if (sa == NULL) {