1 /* 2 * Copyright (c) 2015-2017 Apple Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. The rights granted to you under the License 10 * may not be used to create, or enable the creation or redistribution of, 11 * unlawful or unlicensed copies of an Apple operating system, or to 12 * circumvent, violate, or enable the circumvention or violation of, any 13 * terms of an Apple operating system software license agreement. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 18 * The Original Code and all software distributed under the License are 19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23 * Please see the License for the specific language governing rights and 24 * limitations under the License. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 29 #ifndef __NETINET_IN_TCLASS_H__ 30 #define __NETINET_IN_TCLASS_H__ 31 32 #ifdef PRIVATE 33 34 #include <sys/types.h> 35 #include <sys/socket.h> 36 #include <sys/socketvar.h> 37 #include <sys/mbuf.h> 38 #include <net/if.h> 39 #include <net/if_var.h> 40 41 #define SO_TCDBG_PID 0x01 /* Set/get traffic class policy for PID */ 42 #define SO_TCDBG_PNAME 0x02 /* Set/get traffic class policy for processes of that name */ 43 #define SO_TCDBG_PURGE 0x04 /* Purge entries for unused PIDs */ 44 #define SO_TCDBG_FLUSH 0x08 /* Flush all entries */ 45 #define SO_TCDBG_COUNT 0x10 /* Get count of entries */ 46 #define SO_TCDBG_LIST 0x20 /* List entries */ 47 #define SO_TCDBG_DELETE 0x40 /* Delete a process entry */ 48 #define SO_TCDBG_TCFLUSH_PID 0x80 /* Flush traffic class for PID */ 49 50 struct so_tcdbg { 51 u_int32_t so_tcdbg_cmd; 52 int32_t so_tcdbg_tclass; 53 int32_t so_tcdbg_netsvctype; 54 uint8_t so_tcdbg_ecn_val; /* 1 is ECT(1) and 2 is ECT(0) */ 55 u_int32_t so_tcdbg_count; 56 pid_t so_tcdbg_pid; 57 u_int32_t so_tcbbg_qos_mode; 58 char so_tcdbg_pname[(2 * MAXCOMLEN) + 1]; 59 }; 60 #define QOS_MODE_MARKING_POLICY_DEFAULT 0 61 #define QOS_MODE_MARKING_POLICY_ENABLE 1 62 #define QOS_MODE_MARKING_POLICY_DISABLE 2 63 64 #define NET_QOS_MARKING_POLICY_DEFAULT QOS_MODE_MARKING_POLICY_DEFAULT /* obsolete, to be removed */ 65 #define NET_QOS_MARKING_POLICY_ENABLE QOS_MODE_MARKING_POLICY_ENABLE /* obsolete, to be removed */ 66 #define NET_QOS_MARKING_POLICY_DISABLE QOS_MODE_MARKING_POLICY_DISABLE /* obsolete, to be removed */ 67 68 struct net_qos_param { 69 u_int64_t nq_transfer_size; /* transfer size in bytes */ 70 u_int32_t nq_use_expensive:1, /* allowed = 1 otherwise 0 */ 71 nq_uplink:1, /* uplink = 1 otherwise 0 */ 72 nq_use_constrained:1; /* allowed = 1 otherwise 0 */ 73 u_int32_t nq_unused; /* for future expansion */ 74 }; 75 76 #ifndef KERNEL 77 78 /* 79 * Returns whether a large upload or download transfer should be marked as 80 * BK service type for network activity. This is a system level 81 * hint/suggestion to classify application traffic based on statistics 82 * collected from the current network attachment 83 * 84 * @param param transfer parameters 85 * @param param_len parameter length 86 * @return returns 1 for BK and 0 for default 87 */ 88 extern int net_qos_guideline(struct net_qos_param *param, size_t param_len); 89 90 #endif /* !KERNEL */ 91 92 #ifdef BSD_KERNEL_PRIVATE 93 94 extern int net_qos_policy_restricted; 95 extern int net_qos_policy_wifi_enabled; 96 extern int net_qos_policy_capable_enabled; 97 98 extern void net_qos_map_init(void); 99 extern void net_qos_map_change(uint32_t mode); 100 extern errno_t set_packet_qos(struct mbuf *, struct ifnet *, boolean_t, int, 101 int, u_int8_t *); 102 extern int so_get_netsvc_marking_level(struct socket *); 103 104 extern uint8_t fastlane_sc_to_dscp(uint32_t svc_class); 105 extern uint8_t rfc4594_sc_to_dscp(uint32_t svc_class); 106 extern uint8_t custom_sc_to_dscp(uint32_t svc_class); 107 108 extern mbuf_traffic_class_t rfc4594_dscp_to_tc(uint8_t dscp); 109 110 #endif /* BSD_KERNEL_PRIVATE */ 111 112 #endif /* PRIVATE */ 113 114 #endif /* __NETINET_IN_TCLASS_H__ */ 115