dscp revision 313b0ea9f258edd8530f4454c69e6ba194280162
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCopyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
d10874603bd220a54b929df6290858380ff05eb7vboxsyncSee COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
d10874603bd220a54b929df6290858380ff05eb7vboxsync Differentiate Services Code Point Support
d10874603bd220a54b929df6290858380ff05eb7vboxsync$Id: dscp,v 1.1.2.1 2012/02/24 05:20:36 marka Exp $
d10874603bd220a54b929df6290858380ff05eb7vboxsyncDifferentiate Services Code Point (DSCP) is implemented in IPv4 using the
d10874603bd220a54b929df6290858380ff05eb7vboxsyncTOS octet and in IPv6 using the TCLASS octet.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncRFC 3542 defines the api to manipulate the TCLASS octet as part of
d10874603bd220a54b929df6290858380ff05eb7vboxsyncthe advanced socket API. TCLASS is settable on both a socket and
d10874603bd220a54b929df6290858380ff05eb7vboxsyncpacket basis (setsockopt/sendmsg) and the sent value can be retrieved
d10874603bd220a54b929df6290858380ff05eb7vboxsyncusing recvmsg over UDP. Retrieval is undefined for TCP.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncThe Advanced socket API was not incorporated into the POSIX socket
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAPI for IPv6 and may not be completely implemented in any OS.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncFor TOS setsockopt() supports setting of the field on a persocket
d10874603bd220a54b929df6290858380ff05eb7vboxsyncbasis. TOS may also be set on a per packet basis on some OS using
d10874603bd220a54b929df6290858380ff05eb7vboxsyncsendmsg. If it is not supported the sendmsg call reports a error.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncSupport can only be determined by attempted to send a packet with
d10874603bd220a54b929df6290858380ff05eb7vboxsyncthe option set. Retrieval of the sent TOS value is retrievable on
d10874603bd220a54b929df6290858380ff05eb7vboxsyncLinux. This can be determined at compile time.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncDSCP values need to be compatible with TOS values as it is a re-use
d10874603bd220a54b929df6290858380ff05eb7vboxsyncof the field.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncWe will need to be able to probe for the level of DSCP support. We
d10874603bd220a54b929df6290858380ff05eb7vboxsyncneed to know if we can set it at the socket level, packet level and
d10874603bd220a54b929df6290858380ff05eb7vboxsyncif we can retrieve the DSCP value sent. This needs to be done
d10874603bd220a54b929df6290858380ff05eb7vboxsyncindependently for IPv4 and IPv6.
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPRECVV4 0x01 /* Can receive sent DSCP value IPv4 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPRECVV6 0x02 /* Can receive sent DSCP value IPv6 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPSETV4 0x04 /* Can set DSCP on socket IPv4 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPSETV6 0x08 /* Can set DSCP on socket IPv6 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPPKTV4 0x10 /* Can set DSCP on per packet IPv4 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPPKTV6 0x20 /* Can set DSCP on per packet IPv6 */
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_NET_DSCPALL 0x3f /* All valid flags */
d10874603bd220a54b929df6290858380ff05eb7vboxsyncunsigned int
d10874603bd220a54b929df6290858380ff05eb7vboxsyncisc_net_probedscp(void);
d10874603bd220a54b929df6290858380ff05eb7vboxsync * Probe the level of DSCP support.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncWe also need to be able to set DSCP values on a per socket basis, per packet
d10874603bd220a54b929df6290858380ff05eb7vboxsyncbasis and to retrieve dscp values from received packet.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncSetting dscp on a per socket basis shall be done using isc_socket_dscp.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncisc_socket_dscp(isc_socket_t *sock, unsigned int dscp);
d10874603bd220a54b929df6290858380ff05eb7vboxsync * Requires:
d10874603bd220a54b929df6290858380ff05eb7vboxsync *\li 'sock' is a valid socket.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncisc_socketevent shall be extended to support the sending of and retrieval
d10874603bd220a54b929df6290858380ff05eb7vboxsyncof DSCP values. If ISC_SOCKEVENTATTR_DSCP is set then isc_socket_sendto2
d10874603bd220a54b929df6290858380ff05eb7vboxsyncshall set the DSCP value. isc_socket_recv shall set ISC_SOCKEVENTATTR_DSCP
d10874603bd220a54b929df6290858380ff05eb7vboxsyncand the dscp element if the OS returns the value via recvmsg.
d10874603bd220a54b929df6290858380ff05eb7vboxsync#define ISC_SOCKEVENTATTR_DSCP 0x00040000U /* public */
d10874603bd220a54b929df6290858380ff05eb7vboxsyncstruct isc_socketevent {
d10874603bd220a54b929df6290858380ff05eb7vboxsync ISC_EVENT_COMMON(isc_socketevent_t);
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_result_t result; /*%< OK, EOF, whatever else */
d10874603bd220a54b929df6290858380ff05eb7vboxsync unsigned int minimum; /*%< minimum i/o for event */
d10874603bd220a54b929df6290858380ff05eb7vboxsync unsigned int n; /*%< bytes read or written */
d10874603bd220a54b929df6290858380ff05eb7vboxsync unsigned int offset; /*%< offset into buffer list */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_region_t region; /*%< for single-buffer i/o */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_bufferlist_t bufferlist; /*%< list of buffers */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_sockaddr_t address; /*%< source address */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_time_t timestamp; /*%< timestamp of packet recv */
d10874603bd220a54b929df6290858380ff05eb7vboxsync struct in6_pktinfo pktinfo; /*%< ipv6 pktinfo */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_uint32_t attributes; /*%< see below */
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_eventdestructor_t destroy; /*%< original destructor */
d10874603bd220a54b929df6290858380ff05eb7vboxsync unsigned int dscp; /*%< UDP dscp value */
d10874603bd220a54b929df6290858380ff05eb7vboxsyncA convience function will be provided to allocate and intialize the structure.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncisc_socketevent_t *
d10874603bd220a54b929df6290858380ff05eb7vboxsyncisc_socket_socketevent(isc_socket_t *sock0, isc_eventtype_t eventtype,
d10874603bd220a54b929df6290858380ff05eb7vboxsync isc_taskaction_t action, const void *arg)
d10874603bd220a54b929df6290858380ff05eb7vboxsyncNamed needs to be able to set the DSCP value of sent traffic. We should
d10874603bd220a54b929df6290858380ff05eb7vboxsyncbe able to set DSCP for all TCP connections.
d10874603bd220a54b929df6290858380ff05eb7vboxsyncFor UDP we should have a default DSCP value for when we can't set this on
d10874603bd220a54b929df6290858380ff05eb7vboxsynca per packet basis with the ability to override for specific destinations.
d10874603bd220a54b929df6290858380ff05eb7vboxsynctcp-dscp <value>;
d10874603bd220a54b929df6290858380ff05eb7vboxsyncudp-dscp <value>;
d10874603bd220a54b929df6290858380ff05eb7vboxsynchttp://bogpeople.com/networking/dscp.shtml list a set of TOS compatible
d10874603bd220a54b929df6290858380ff05eb7vboxsyncvalues (below).
d10874603bd220a54b929df6290858380ff05eb7vboxsyncDSCP Name DS Field Value IP Precedence
d10874603bd220a54b929df6290858380ff05eb7vboxsync Binary Decimal
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS0 000 000 0 0
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS1 001 000 8 1
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF11 001 010 10 1
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF12 001 100 12 1
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF13 001 110 14 1
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS2 010 000 16 2
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF21 010 010 18 2
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF22 010 100 20 2
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF23 010 110 22 2
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS3 011 000 24 3
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF31 011 010 26 3
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF32 011 100 28 3
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF33 011 110 30 3
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS4 100 000 32 4
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF41 100 010 34 4
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF42 100 100 36 4
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAF43 100 110 38 4
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS5 101 000 40 5
d10874603bd220a54b929df6290858380ff05eb7vboxsyncEF 101 110 46 5
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS6 110 000 48 6
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS7 111 000 56 7
d10874603bd220a54b929df6290858380ff05eb7vboxsyncCS Class Selector (RFC 2474)
d10874603bd220a54b929df6290858380ff05eb7vboxsyncAFxy Assured Forwarding (x=class, y=drop precedence) (RFC2597)
d10874603bd220a54b929df6290858380ff05eb7vboxsyncEF Expedited Forwarding (RFC 3246)
d10874603bd220a54b929df6290858380ff05eb7vboxsyncvalue should be one of these or a numeric 0..63. The default value is 0.