mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #13671 from balajicyp/topic/setsockopt_ip_tos
Add an socket option to set type of service to set specific precedence for QoSpull/13918/head
commit
1bd5ce6af2
|
@ -665,6 +665,12 @@ nsapi_error_t LWIP::setsockopt(nsapi_socket_t handle, int level, int optname, co
|
|||
return err_remap(igmp_err);
|
||||
}
|
||||
|
||||
case NSAPI_IPTOS:
|
||||
if (optlen != sizeof(u8_t)) {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
s->conn->pcb.ip->tos = (u8_t)(*(const int *)optval);
|
||||
return 0;
|
||||
default:
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,50 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* The Type of Service provides an indication of the abstract
|
||||
* parameters of the quality of service desired. These parameters are
|
||||
* to be used to guide the selection of the actual service parameters
|
||||
* when transmitting a datagram through a particular network. Several
|
||||
* networks offer service precedence, which somehow treats high
|
||||
* precedence traffic as more important than other traffic (generally
|
||||
* by accepting only traffic above a certain precedence at time of high
|
||||
* load). The major choice is a three way tradeoff between low-delay,
|
||||
* high-reliability, and high-throughput.
|
||||
* The use of the Delay, Throughput, and Reliability indications may
|
||||
* increase the cost (in some sense) of the service. In many networks
|
||||
* better performance for one of these parameters is coupled with worse
|
||||
* performance on another. Except for very unusual cases at most two
|
||||
* of these three indications should be set.
|
||||
*/
|
||||
#define NSAPI_IPTOS_TOS_MASK 0x1E
|
||||
#define NSAPI_IPTOS_TOS(tos) ((tos) & IPTOS_TOS_MASK)
|
||||
#define NSAPI_IPTOS_LOWDELAY 0x10
|
||||
#define NSAPI_IPTOS_THROUGHPUT 0x08
|
||||
#define NSAPI_IPTOS_RELIABILITY 0x04
|
||||
#define NSAPI_IPTOS_LOWCOST 0x02
|
||||
#define NSAPI_IPTOS_MINCOST IPTOS_LOWCOST
|
||||
|
||||
/*
|
||||
* The Network Control precedence designation is intended to be used
|
||||
* within a network only. The actual use and control of that
|
||||
* designation is up to each network. The Internetwork Control
|
||||
* designation is intended for use by gateway control originators only.
|
||||
* If the actual use of these precedence designations is of concern to
|
||||
* a particular network, it is the responsibility of that network to
|
||||
* control the access to, and use of, those precedence designations.
|
||||
*/
|
||||
#define NSAPI_IPTOS_PREC_MASK 0xe0
|
||||
#define NSAPI_IPTOS_PREC(tos) ((tos) & IPTOS_PREC_MASK)
|
||||
#define NSAPI_IPTOS_PREC_NETCONTROL 0xe0
|
||||
#define NSAPI_IPTOS_PREC_INTERNETCONTROL 0xc0
|
||||
#define NSAPI_IPTOS_PREC_CRITIC_ECP 0xa0
|
||||
#define NSAPI_IPTOS_PREC_FLASHOVERRIDE 0x80
|
||||
#define NSAPI_IPTOS_PREC_FLASH 0x60
|
||||
#define NSAPI_IPTOS_PREC_IMMEDIATE 0x40
|
||||
#define NSAPI_IPTOS_PREC_PRIORITY 0x20
|
||||
#define NSAPI_IPTOS_PREC_ROUTINE 0x00
|
||||
|
||||
/** Enum of standardized error codes
|
||||
*
|
||||
* Valid error codes have negative values and may
|
||||
|
@ -273,6 +317,7 @@ typedef enum nsapi_socket_option {
|
|||
NSAPI_BIND_TO_DEVICE, /*!< Bind socket network interface name*/
|
||||
NSAPI_LATENCY, /*!< Read estimated latency to destination */
|
||||
NSAPI_STAGGER, /*!< Read estimated stagger value to destination */
|
||||
NSAPI_IPTOS, /*!< Set IP type of service to set specific precedence */
|
||||
} nsapi_socket_option_t;
|
||||
|
||||
typedef enum nsapi_tlssocket_level {
|
||||
|
|
Loading…
Reference in New Issue