mirror of
https://github.com/curl/curl.git
synced 2025-09-13 07:32:38 +03:00
curl: support VLAN Priority: --vlan-priority
Add --vlan-priority option to the command line tool for setting VLAN priority. Closes #13907
This commit is contained in:
parent
1445b7ae23
commit
54fe8c44e1
1
.github/scripts/spellcheck.words
vendored
1
.github/scripts/spellcheck.words
vendored
|
@ -908,6 +908,7 @@ VC
|
||||||
vcpkg
|
vcpkg
|
||||||
vexxhost
|
vexxhost
|
||||||
Viktor
|
Viktor
|
||||||
|
VLAN
|
||||||
VM
|
VM
|
||||||
VMS
|
VMS
|
||||||
VMware
|
VMware
|
||||||
|
|
|
@ -304,5 +304,6 @@ DPAGES = \
|
||||||
variable.md \
|
variable.md \
|
||||||
verbose.md \
|
verbose.md \
|
||||||
version.md \
|
version.md \
|
||||||
|
vlan-priority.md \
|
||||||
write-out.md \
|
write-out.md \
|
||||||
xattr.md
|
xattr.md
|
||||||
|
|
|
@ -10,6 +10,7 @@ Protocols: All
|
||||||
Multi: single
|
Multi: single
|
||||||
See-also:
|
See-also:
|
||||||
- tcp-nodelay
|
- tcp-nodelay
|
||||||
|
- vlan-priority
|
||||||
Example:
|
Example:
|
||||||
- --ip-tos CS5 $URL
|
- --ip-tos CS5 $URL
|
||||||
---
|
---
|
||||||
|
|
23
docs/cmdline-opts/vlan-priority.md
Normal file
23
docs/cmdline-opts/vlan-priority.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
SPDX-License-Identifier: curl
|
||||||
|
Long: vlan-priority
|
||||||
|
Arg: <priority>
|
||||||
|
Help: Set VLAN priority
|
||||||
|
Added: 8.9.0
|
||||||
|
Category: connection
|
||||||
|
Protocols: All
|
||||||
|
Multi: single
|
||||||
|
See-also:
|
||||||
|
- ip-tos
|
||||||
|
Example:
|
||||||
|
- --vlan-priority 4 $URL
|
||||||
|
---
|
||||||
|
|
||||||
|
# `--vlan-priority`
|
||||||
|
|
||||||
|
Set VLAN priority as defined in IEEE 802.1Q. (Added in 8.9.0).
|
||||||
|
|
||||||
|
This field is set on Ethernet level, and only works within a local network.
|
||||||
|
|
||||||
|
The valid range for \<priority\> is 0 to 7.
|
|
@ -269,5 +269,6 @@
|
||||||
--variable 8.3.0
|
--variable 8.3.0
|
||||||
--verbose (-v) 4.0
|
--verbose (-v) 4.0
|
||||||
--version (-V) 4.0
|
--version (-V) 4.0
|
||||||
|
--vlan-priority 8.9.0
|
||||||
--write-out (-w) 6.5
|
--write-out (-w) 6.5
|
||||||
--xattr 7.21.3
|
--xattr 7.21.3
|
||||||
|
|
|
@ -86,6 +86,7 @@ struct OperationConfig {
|
||||||
long low_speed_limit;
|
long low_speed_limit;
|
||||||
long low_speed_time;
|
long low_speed_time;
|
||||||
long ip_tos; /* IP Type of Service */
|
long ip_tos; /* IP Type of Service */
|
||||||
|
long vlan_priority; /* VLAN priority */
|
||||||
char *dns_servers; /* dot notation: 1.1.1.1;2.2.2.2 */
|
char *dns_servers; /* dot notation: 1.1.1.1;2.2.2.2 */
|
||||||
char *dns_interface; /* interface name */
|
char *dns_interface; /* interface name */
|
||||||
char *dns_ipv4_addr; /* dot notation */
|
char *dns_ipv4_addr; /* dot notation */
|
||||||
|
|
|
@ -340,6 +340,7 @@ typedef enum {
|
||||||
C_VARIABLE,
|
C_VARIABLE,
|
||||||
C_VERBOSE,
|
C_VERBOSE,
|
||||||
C_VERSION,
|
C_VERSION,
|
||||||
|
C_VLAN_PRIORITY,
|
||||||
C_WDEBUG,
|
C_WDEBUG,
|
||||||
C_WRITE_OUT,
|
C_WRITE_OUT,
|
||||||
C_XATTR
|
C_XATTR
|
||||||
|
@ -624,6 +625,7 @@ static const struct LongShort aliases[]= {
|
||||||
{"variable", ARG_STRG, ' ', C_VARIABLE},
|
{"variable", ARG_STRG, ' ', C_VARIABLE},
|
||||||
{"verbose", ARG_BOOL, 'v', C_VERBOSE},
|
{"verbose", ARG_BOOL, 'v', C_VERBOSE},
|
||||||
{"version", ARG_BOOL, 'V', C_VERSION},
|
{"version", ARG_BOOL, 'V', C_VERSION},
|
||||||
|
{"vlan-priority", ARG_STRG, ' ', C_VLAN_PRIORITY},
|
||||||
#ifdef USE_WATT32
|
#ifdef USE_WATT32
|
||||||
{"wdebug", ARG_BOOL, ' ', C_WDEBUG},
|
{"wdebug", ARG_BOOL, ' ', C_WDEBUG},
|
||||||
#endif
|
#endif
|
||||||
|
@ -1690,6 +1692,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
||||||
err = str2unummax(&config->ip_tos, nextarg, 0xFF);
|
err = str2unummax(&config->ip_tos, nextarg, 0xFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case C_VLAN_PRIORITY: /* --vlan-priority */
|
||||||
|
err = str2unummax(&config->vlan_priority, nextarg, 7);
|
||||||
|
break;
|
||||||
case C_PROXY_DIGEST: /* --proxy-digest */
|
case C_PROXY_DIGEST: /* --proxy-digest */
|
||||||
config->proxydigest = toggle;
|
config->proxydigest = toggle;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -810,6 +810,9 @@ const struct helptxt helptext[] = {
|
||||||
{"-V, --version",
|
{"-V, --version",
|
||||||
"Show version number and quit",
|
"Show version number and quit",
|
||||||
CURLHELP_IMPORTANT | CURLHELP_CURL},
|
CURLHELP_IMPORTANT | CURLHELP_CURL},
|
||||||
|
{" --vlan-priority <priority>",
|
||||||
|
"Set VLAN priority",
|
||||||
|
CURLHELP_CONNECTION},
|
||||||
{"-w, --write-out <format>",
|
{"-w, --write-out <format>",
|
||||||
"Output FORMAT after completion",
|
"Output FORMAT after completion",
|
||||||
CURLHELP_VERBOSE},
|
CURLHELP_VERBOSE},
|
||||||
|
|
|
@ -162,7 +162,7 @@ static int get_address_family(curl_socket_t sockfd)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
#if defined(IP_TOS) || defined(IPV6_TCLASS) || defined(SO_PRIORITY)
|
||||||
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
||||||
curlsocktype purpose)
|
curlsocktype purpose)
|
||||||
{
|
{
|
||||||
|
@ -171,6 +171,7 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
||||||
return CURL_SOCKOPT_OK;
|
return CURL_SOCKOPT_OK;
|
||||||
(void)config;
|
(void)config;
|
||||||
(void)curlfd;
|
(void)curlfd;
|
||||||
|
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
||||||
if(config->ip_tos > 0) {
|
if(config->ip_tos > 0) {
|
||||||
int tos = (int)config->ip_tos;
|
int tos = (int)config->ip_tos;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
@ -195,6 +196,18 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
||||||
tos, error, strerror(error));
|
tos, error, strerror(error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef SO_PRIORITY
|
||||||
|
if(config->vlan_priority > 0) {
|
||||||
|
int priority = (int)config->vlan_priority;
|
||||||
|
if(setsockopt(curlfd, SOL_SOCKET, SO_PRIORITY,
|
||||||
|
(const char *)&priority, sizeof(priority)) != 0) {
|
||||||
|
int error = errno;
|
||||||
|
warnf(config->global, "VLAN priority %d failed with errno %d: %s;\n",
|
||||||
|
priority, error, strerror(error));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return CURL_SOCKOPT_OK;
|
return CURL_SOCKOPT_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2253,13 +2266,21 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* new in 8.9.0 */
|
/* new in 8.9.0 */
|
||||||
if(config->ip_tos > 0) {
|
if(config->ip_tos > 0 || config->vlan_priority > 0) {
|
||||||
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
#if defined(IP_TOS) || defined(IPV6_TCLASS) || defined(SO_PRIORITY)
|
||||||
my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
|
my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
|
||||||
my_setopt(curl, CURLOPT_SOCKOPTDATA, config);
|
my_setopt(curl, CURLOPT_SOCKOPTDATA, config);
|
||||||
#else
|
#else
|
||||||
warnf(config->global,
|
if(config->ip_tos > 0) {
|
||||||
"Type of service is not supported in this build.");
|
errorf(config->global,
|
||||||
|
"Type of service is not supported in this build.");
|
||||||
|
result = CURLE_NOT_BUILT_IN;
|
||||||
|
}
|
||||||
|
if(config->vlan_priority > 0) {
|
||||||
|
errorf(config->global,
|
||||||
|
"VLAN priority is not supported in this build.");
|
||||||
|
result = CURLE_NOT_BUILT_IN;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user