Imported Upstream version 2.72.alpha
[platform/upstream/glib-networking.git] / tls / tests / lossy-socket.h
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  * Copyright (C) 2021 Ole André Vadla Ravnås <oleavr@frida.re>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 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  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General
16  * Public License along with this library; if not, see
17  * <http://www.gnu.org/licenses/>.
18  */
19
20 #include <gio/gio.h>
21
22 #pragma once
23
24 G_BEGIN_DECLS
25
26 typedef enum {
27   IO_KEEP,
28   IO_DROP
29 } IODecision;
30
31 typedef enum {
32   IO_IN,
33   IO_OUT
34 } IODirection;
35
36 typedef struct _IODetails IODetails;
37
38 typedef IODecision (*IOPredicateFunc) (const IODetails *io,
39                                        gpointer         user_data);
40
41 struct _IODetails
42 {
43   IODirection direction;
44   guint serial;
45 };
46
47 #define LOSSY_TYPE_SOCKET (lossy_socket_get_type ())
48
49 G_DECLARE_FINAL_TYPE (LossySocket, lossy_socket, LOSSY, SOCKET, GObject)
50
51 GDatagramBased *lossy_socket_new (GDatagramBased  *base_socket,
52                                   IOPredicateFunc  predicate_func,
53                                   gpointer         predicate_data);
54
55 G_END_DECLS