/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities the gir-to-d pakage


module gio.IPv6TclassMessage;

private import gio.SocketControlMessage;
private import gio.c.functions;
public  import gio.c.types;
private import glib.ConstructionException;
private import gobject.ObjectG;


/**
 * Contains the Traffic Class byte of an IPv6 header.
 * 
 * This consists of the DSCP field as per
 * [RFC 2474](https://www.rfc-editor.org/rfc/rfc2474#section-3),
 * and the ECN field as per
 * [RFC 3168](https://www.rfc-editor.org/rfc/rfc3168#section-5).
 * 
 * It may be received using [method@Gio.Socket.receive_message] over UDP sockets
 * (i.e. sockets in the `G_SOCKET_FAMILY_IPV6` family with
 * `G_SOCKET_TYPE_DATAGRAM` type). The message is not meant for sending. To set
 * Traffic Class field to be used in datagrams sent on a [class@Gio.Socket] use:
 * ```c
 * g_socket_set_option (socket, IPPROTO_IPV6, IPV6_TCLASS, <TC value>, &error);
 * ```
 *
 * Since: 2.88
 */
public class IPv6TclassMessage : SocketControlMessage
{
	/** the main Gtk struct */
	protected GIPv6TclassMessage* gIPv6TclassMessage;

	/** Get the main Gtk struct */
	public GIPv6TclassMessage* getIPv6TclassMessageStruct(bool transferOwnership = false)
	{
		if (transferOwnership)
			ownedRef = false;
		return gIPv6TclassMessage;
	}

	/** the main Gtk struct as a void* */
	protected override void* getStruct()
	{
		return cast(void*)gIPv6TclassMessage;
	}

	/**
	 * Sets our main struct and passes it to the parent class.
	 */
	public this (GIPv6TclassMessage* gIPv6TclassMessage, bool ownedRef = false)
	{
		this.gIPv6TclassMessage = gIPv6TclassMessage;
		super(cast(GSocketControlMessage*)gIPv6TclassMessage, ownedRef);
	}


	/** */
	public static GType getType()
	{
		return g_ipv6_tclass_message_get_type();
	}

	/**
	 * Creates a new traffic class message with given DSCP and ECN values.
	 *
	 * Params:
	 *     dscp = the DSCP value of the message
	 *     ecn = the ECN value of the message
	 *
	 * Returns: a new traffic class message
	 *
	 * Since: 2.88
	 *
	 * Throws: ConstructionException GTK+ fails to create the object.
	 */
	public this(ubyte dscp, GEcnCodePoint ecn)
	{
		auto __p = g_ipv6_tclass_message_new(dscp, ecn);

		if(__p is null)
		{
			throw new ConstructionException("null returned by new");
		}

		this(cast(GIPv6TclassMessage*) __p, true);
	}

	/**
	 * Gets the differentiated services code point stored in @message.
	 *
	 * Returns: A DSCP value as described in [RFC 2474](https://www.rfc-editor.org/rfc/rfc2474.html#section-3).
	 *
	 * Since: 2.88
	 */
	public ubyte getDscp()
	{
		return g_ipv6_tclass_message_get_dscp(gIPv6TclassMessage);
	}

	/**
	 * Gets the Explicit Congestion Notification code point stored in @message.
	 *
	 * Returns: An ECN value as described in [RFC 3168](https://www.rfc-editor.org/rfc/rfc3168#section-5).
	 *
	 * Since: 2.88
	 */
	public GEcnCodePoint getEcn()
	{
		return g_ipv6_tclass_message_get_ecn(gIPv6TclassMessage);
	}
}
