mirror of
https://github.com/curl/curl.git
synced 2025-09-12 23:22:42 +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
|
||||
vexxhost
|
||||
Viktor
|
||||
VLAN
|
||||
VM
|
||||
VMS
|
||||
VMware
|
||||
|
|
|
@ -304,5 +304,6 @@ DPAGES = \
|
|||
variable.md \
|
||||
verbose.md \
|
||||
version.md \
|
||||
vlan-priority.md \
|
||||
write-out.md \
|
||||
xattr.md
|
||||
|
|
|
@ -10,6 +10,7 @@ Protocols: All
|
|||
Multi: single
|
||||
See-also:
|
||||
- tcp-nodelay
|
||||
- vlan-priority
|
||||
Example:
|
||||
- --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
|
||||
--verbose (-v) 4.0
|
||||
--version (-V) 4.0
|
||||
--vlan-priority 8.9.0
|
||||
--write-out (-w) 6.5
|
||||
--xattr 7.21.3
|
||||
|
|
|
@ -86,6 +86,7 @@ struct OperationConfig {
|
|||
long low_speed_limit;
|
||||
long low_speed_time;
|
||||
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_interface; /* interface name */
|
||||
char *dns_ipv4_addr; /* dot notation */
|
||||
|
|
|
@ -340,6 +340,7 @@ typedef enum {
|
|||
C_VARIABLE,
|
||||
C_VERBOSE,
|
||||
C_VERSION,
|
||||
C_VLAN_PRIORITY,
|
||||
C_WDEBUG,
|
||||
C_WRITE_OUT,
|
||||
C_XATTR
|
||||
|
@ -624,6 +625,7 @@ static const struct LongShort aliases[]= {
|
|||
{"variable", ARG_STRG, ' ', C_VARIABLE},
|
||||
{"verbose", ARG_BOOL, 'v', C_VERBOSE},
|
||||
{"version", ARG_BOOL, 'V', C_VERSION},
|
||||
{"vlan-priority", ARG_STRG, ' ', C_VLAN_PRIORITY},
|
||||
#ifdef USE_WATT32
|
||||
{"wdebug", ARG_BOOL, ' ', C_WDEBUG},
|
||||
#endif
|
||||
|
@ -1690,6 +1692,9 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
|
|||
err = str2unummax(&config->ip_tos, nextarg, 0xFF);
|
||||
break;
|
||||
}
|
||||
case C_VLAN_PRIORITY: /* --vlan-priority */
|
||||
err = str2unummax(&config->vlan_priority, nextarg, 7);
|
||||
break;
|
||||
case C_PROXY_DIGEST: /* --proxy-digest */
|
||||
config->proxydigest = toggle;
|
||||
break;
|
||||
|
|
|
@ -810,6 +810,9 @@ const struct helptxt helptext[] = {
|
|||
{"-V, --version",
|
||||
"Show version number and quit",
|
||||
CURLHELP_IMPORTANT | CURLHELP_CURL},
|
||||
{" --vlan-priority <priority>",
|
||||
"Set VLAN priority",
|
||||
CURLHELP_CONNECTION},
|
||||
{"-w, --write-out <format>",
|
||||
"Output FORMAT after completion",
|
||||
CURLHELP_VERBOSE},
|
||||
|
|
|
@ -162,7 +162,7 @@ static int get_address_family(curl_socket_t sockfd)
|
|||
}
|
||||
#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,
|
||||
curlsocktype purpose)
|
||||
{
|
||||
|
@ -171,6 +171,7 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
|||
return CURL_SOCKOPT_OK;
|
||||
(void)config;
|
||||
(void)curlfd;
|
||||
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
||||
if(config->ip_tos > 0) {
|
||||
int tos = (int)config->ip_tos;
|
||||
int result = 0;
|
||||
|
@ -195,6 +196,18 @@ static int sockopt_callback(void *clientp, curl_socket_t curlfd,
|
|||
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;
|
||||
}
|
||||
#endif
|
||||
|
@ -2253,13 +2266,21 @@ static CURLcode single_transfer(struct GlobalConfig *global,
|
|||
#endif
|
||||
|
||||
/* new in 8.9.0 */
|
||||
if(config->ip_tos > 0) {
|
||||
#if defined(IP_TOS) || defined(IPV6_TCLASS)
|
||||
if(config->ip_tos > 0 || config->vlan_priority > 0) {
|
||||
#if defined(IP_TOS) || defined(IPV6_TCLASS) || defined(SO_PRIORITY)
|
||||
my_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback);
|
||||
my_setopt(curl, CURLOPT_SOCKOPTDATA, config);
|
||||
#else
|
||||
warnf(config->global,
|
||||
"Type of service is not supported in this build.");
|
||||
if(config->ip_tos > 0) {
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user