4 * @brief management of sockets
6 * receiver reads from here, sender writes to here
11 * Copyright (C) 2005 Jan Hutter, Martin Willi
12 * Hochschule fuer Technik Rapperswil
14 * This program is free software; you can redistribute it and/or modify it
15 * under the terms of the GNU General Public License as published by the
16 * Free Software Foundation; either version 2 of the License, or (at your
17 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
19 * This program is distributed in the hope that it will be useful, but
20 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
21 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
30 #include <network/packet.h>
34 * maximum size of a packet
35 * 3000 Bytes should be sufficient, see IKEv2 draft
37 #define MAX_PACKET 3000
41 * @brief abstraction of one (ipv4), or in future, of multiple sockets
44 typedef struct socket_s socket_t
;
47 * @brief receive a packet
49 * reads a packet from one of the sockets.
50 * source will be set, dest not implemented
53 * @param sock socket_t object to work on
54 * @param packet pinter gets address from allocated packet_t
55 * @return FAILED when unable to receive
56 * SUCCESS when packet successfully received
58 status_t (*receive
) (socket_t
*sock
, packet_t
**packet
);
61 * @brief send a packet
63 * sends a packet via desired socket.
64 * uses source and dest in packet.
66 * @param sock socket_t object to work on
67 * @param packet[out] packet_t to send
68 * @return FAILED when unable to send
69 * SUCCESS when packet successfully sent
71 status_t (*send
) (socket_t
*sock
, packet_t
*packet
);
74 * @brief destroy sockets
76 * close sockets and destroy socket_t object
78 * @param sock socket_t to destroy
81 status_t (*destroy
) (socket_t
*sock
);
85 * @brief socket_t constructor
87 * currently creates one socket, listening on all addresses
90 * @param port port to bind socket to
91 * @return the created socket, or NULL on error
93 socket_t
*socket_create(u_int16_t port
);