1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #ifndef SOLARIS_SOCKET_OPTIONS_H
  27 #define SOLARIS_SOCKET_OPTIONS_H
  28 
  29 #include <sys/socket.h>
  30 #include <jni.h>
  31 #include <string.h>
  32 #include <errno.h>
  33 #include <unistd.h>
  34 
  35 #include "jni_util.h"
  36 #include "jdk_net_SocketFlow.h"
  37 #include "SolarisSocketOptions.h"
  38 #include "jdk_net_SolarisSocketOptions.h"
  39 
  40 #ifndef SO_FLOW_SLA
  41 #define SO_FLOW_SLA 0x1018
  42 
  43 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
  44 #pragma pack(4)
  45 #endif
  46 
  47 /*
  48  * Used with the setsockopt(SO_FLOW_SLA, ...) call to set
  49  * per socket service level properties.
  50  * When the application uses per-socket API, we will enforce the properties
  51  * on both outbound and inbound packets.
  52  *
  53  * For now, only priority and maxbw are supported in SOCK_FLOW_PROP_VERSION1.
  54  */
  55 typedef struct sock_flow_props_s {
  56         int             sfp_version;
  57         uint32_t        sfp_mask;
  58         int             sfp_priority;   /* flow priority */
  59         uint64_t        sfp_maxbw;      /* bandwidth limit in bps */
  60         int             sfp_status;     /* flow create status for getsockopt */
  61 } sock_flow_props_t;
  62 
  63 #define SOCK_FLOW_PROP_VERSION1 1
  64 
  65 /* bit mask values for sfp_mask */
  66 #define SFP_MAXBW       0x00000001      /* Flow Bandwidth Limit */
  67 #define SFP_PRIORITY    0x00000008      /* Flow priority */
  68 
  69 /* possible values for sfp_priority */
  70 #define SFP_PRIO_NORMAL 1
  71 #define SFP_PRIO_HIGH   2
  72 
  73 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
  74 #pragma pack()
  75 #endif /* _LONG_LONG_ALIGNMENT */
  76 
  77 #endif /* SO_FLOW_SLA */
  78 
  79 #endif /* SOLARIS_SOCKET_OPTIONS_H */