mirror of https://github.com/ARMmbed/mbed-os.git
Add nsapi types for IP TOS and fix opt length check
parent
7f2c00b54c
commit
ada44a62f4
|
@ -665,7 +665,7 @@ nsapi_error_t LWIP::setsockopt(nsapi_socket_t handle, int level, int optname, co
|
||||||
}
|
}
|
||||||
|
|
||||||
case NSAPI_IPTOS:
|
case NSAPI_IPTOS:
|
||||||
if (optlen != sizeof(int)) {
|
if (optlen != sizeof(u8_t)) {
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
return NSAPI_ERROR_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
s->conn->pcb.ip->tos = (u8_t)(*(const int *)optval);
|
s->conn->pcb.ip->tos = (u8_t)(*(const int *)optval);
|
||||||
|
|
|
@ -27,6 +27,50 @@ extern "C" {
|
||||||
#endif
|
#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
|
/** Enum of standardized error codes
|
||||||
*
|
*
|
||||||
* Valid error codes have negative values and may
|
* Valid error codes have negative values and may
|
||||||
|
|
Loading…
Reference in New Issue