![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-or-later */ 0002 /* 0003 * inet_dscp.h: helpers for handling differentiated services codepoints (DSCP) 0004 * 0005 * DSCP is defined in RFC 2474: 0006 * 0007 * 0 1 2 3 4 5 6 7 0008 * +---+---+---+---+---+---+---+---+ 0009 * | DSCP | CU | 0010 * +---+---+---+---+---+---+---+---+ 0011 * 0012 * DSCP: differentiated services codepoint 0013 * CU: currently unused 0014 * 0015 * The whole DSCP + CU bits form the DS field. 0016 * The DS field is also commonly called TOS or Traffic Class (for IPv6). 0017 * 0018 * Note: the CU bits are now used for Explicit Congestion Notification 0019 * (RFC 3168). 0020 */ 0021 0022 #ifndef _INET_DSCP_H 0023 #define _INET_DSCP_H 0024 0025 #include <linux/types.h> 0026 0027 /* Special type for storing DSCP values. 0028 * 0029 * A dscp_t variable stores a DS field with the CU (ECN) bits cleared. 0030 * Using dscp_t allows to strictly separate DSCP and ECN bits, thus avoiding 0031 * bugs where ECN bits are erroneously taken into account during FIB lookups 0032 * or policy routing. 0033 * 0034 * Note: to get the real DSCP value contained in a dscp_t variable one would 0035 * have to do a bit shift after calling inet_dscp_to_dsfield(). We could have 0036 * a helper for that, but there's currently no users. 0037 */ 0038 typedef u8 __bitwise dscp_t; 0039 0040 #define INET_DSCP_MASK 0xfc 0041 0042 static inline dscp_t inet_dsfield_to_dscp(__u8 dsfield) 0043 { 0044 return (__force dscp_t)(dsfield & INET_DSCP_MASK); 0045 } 0046 0047 static inline __u8 inet_dscp_to_dsfield(dscp_t dscp) 0048 { 0049 return (__force __u8)dscp; 0050 } 0051 0052 static inline bool inet_validate_dscp(__u8 val) 0053 { 0054 return !(val & ~INET_DSCP_MASK); 0055 } 0056 0057 #endif /* _INET_DSCP_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |