"Fossies" - the Fresh Open Source Software Archive

Member "gstreamer-1.16.1/libs/gst/net/gstnetutils.c" (19 Apr 2019, 1776 Bytes) of package /linux/misc/gstreamer-1.16.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "gstnetutils.c" see the Fossies "Dox" file reference documentation.

    1 /* GStreamer
    2  * Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
    3  * Copyright (C) 2017 Robert Rosengren <robertr@axis.com>
    4  *
    5  * This library is free software; you can redistribute it and/or
    6  * modify it under the terms of the GNU Library General Public
    7  * License as published by the Free Software Foundation; either
    8  * version 2 of the License, or (at your option) any later version.
    9  *
   10  * This library is distributed in the hope that it will be useful,
   11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   13  * Library General Public License for more details.
   14  *
   15  * You should have received a copy of the GNU Library General Public
   16  * License along with this library; if not, write to the
   17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
   18  * Boston, MA 02110-1301, USA.
   19  */
   20 
   21 #ifdef HAVE_CONFIG_H
   22 #include "config.h"
   23 #endif
   24 
   25 #include "gstnetutils.h"
   26 #include <gst/gstinfo.h>
   27 #include <errno.h>
   28 
   29 #ifdef HAVE_SYS_SOCKET_H
   30 #include <sys/socket.h>
   31 #endif
   32 
   33 #ifndef G_OS_WIN32
   34 #include <netinet/in.h>
   35 #endif
   36 
   37 /**
   38  * gst_net_time_packet_util_set_dscp:
   39  * @socket: Socket to configure
   40  * @qos_dscp: QoS DSCP value
   41  *
   42  * Configures IP_TOS value of socket, i.e. sets QoS DSCP.
   43  *
   44  * Returns: TRUE if successful, FALSE in case an error occurred.
   45  */
   46 gboolean
   47 gst_net_utils_set_socket_dscp (GSocket * socket, gint qos_dscp)
   48 {
   49   gboolean ret = FALSE;
   50 
   51 #ifdef IP_TOS
   52   gint tos, fd;
   53   fd = g_socket_get_fd (socket);
   54 
   55   /* Extract and shift 6 bits of DSFIELD */
   56   tos = (qos_dscp & 0x3f) << 2;
   57 
   58   if (setsockopt (fd, IPPROTO_IP, IP_TOS, &tos, sizeof (tos)) < 0) {
   59     GST_ERROR ("could not set TOS: %s", g_strerror (errno));
   60   } else {
   61     ret = TRUE;
   62   }
   63 #endif
   64 
   65   return ret;
   66 }