]> git.ipfire.org Git - thirdparty/strongswan.git/blame - src/libcharon/network/socket_manager.h
Update copyright headers after acquisition by secunet
[thirdparty/strongswan.git] / src / libcharon / network / socket_manager.h
CommitLineData
dab05604 1/*
eafd7ee7 2 * Copyright (C) 2010-2013 Tobias Brunner
dab05604 3 * Copyright (C) 2010 Martin Willi
19ef2aec
TB
4 *
5 * Copyright (C) secunet Security Networks AG
dab05604
MW
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18/**
19 * @defgroup socket_manager socket_manager
20 * @{ @ingroup network
21 */
22
23#ifndef SOCKET_MANAGER_H_
24#define SOCKET_MANAGER_H_
25
26#include <network/socket.h>
27
28typedef struct socket_manager_t socket_manager_t;
29
30/**
31 * Handle pluggable socket implementations and send/receive packets through it.
32 */
33struct socket_manager_t {
34
35 /**
36 * Receive a packet using the registered socket.
37 *
38 * @param packet allocated packet that has been received
39 * @return
40 * - SUCCESS when packet successfully received
41 * - FAILED when unable to receive
42 */
eafd7ee7 43 status_t (*receive)(socket_manager_t *this, packet_t **packet);
dab05604
MW
44
45 /**
46 * Send a packet using the registered socket.
47 *
48 * @param packet packet to send out
49 * @return
50 * - SUCCESS when packet successfully sent
51 * - FAILED when unable to send
52 */
eafd7ee7 53 status_t (*send)(socket_manager_t *this, packet_t *packet);
dab05604 54
a7babe25
TB
55 /**
56 * Get the port the registered socket is listening on.
57 *
58 * @param nat_t TRUE to get the port used to float in case of NAT-T
59 * @return the port, or 0, if no socket is registered
60 */
b12c53ce 61 uint16_t (*get_port)(socket_manager_t *this, bool nat_t);
eafd7ee7
TB
62
63 /**
64 * Get the address families the registered socket is listening on.
65 *
66 * @return address families
67 */
68 socket_family_t (*supported_families)(socket_manager_t *this);
a7babe25 69
dab05604 70 /**
fa208494
TB
71 * Register a socket constructor.
72 *
73 * @param create constructor for the socket
dab05604 74 */
fa208494 75 void (*add_socket)(socket_manager_t *this, socket_constructor_t create);
dab05604
MW
76
77 /**
fa208494
TB
78 * Unregister a registered socket constructor.
79 *
80 * @param create constructor for the socket
dab05604 81 */
fa208494 82 void (*remove_socket)(socket_manager_t *this, socket_constructor_t create);
dab05604
MW
83
84 /**
85 * Destroy a socket_manager_t.
86 */
87 void (*destroy)(socket_manager_t *this);
88};
89
90/**
91 * Create a socket_manager instance.
92 */
93socket_manager_t *socket_manager_create();
94
95#endif /** SOCKET_MANAGER_H_ @}*/