4 * @brief Interface for socket_t.
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 #include <network/packet.h>
32 * @brief Maximum size of a packet.
34 * 3000 Bytes should be sufficient, see IKEv2 draft
38 #define MAX_PACKET 3000
41 typedef struct socket_t socket_t
;
44 * @brief Abstraction of one (ipv4), or in future, of multiple sockets.
46 * Receiver reads from here, sender writes to here.
52 * @brief Receive a packet.
54 * reads a packet from one of the sockets.
55 * source will be set, dest not implemented
58 * @param sock socket_t object to work on
59 * @param packet pinter gets address from allocated packet_t
60 * @return FAILED when unable to receive
61 * SUCCESS when packet successfully received
63 status_t (*receive
) (socket_t
*sock
, packet_t
**packet
);
66 * @brief Send a packet.
68 * sends a packet via desired socket.
69 * uses source and dest in packet.
71 * @param sock socket_t object to work on
72 * @param packet[out] packet_t to send
73 * @return FAILED when unable to send
74 * SUCCESS when packet successfully sent
76 status_t (*send
) (socket_t
*sock
, packet_t
*packet
);
79 * @brief Destroy sockets.
81 * close sockets and destroy socket_t object
83 * @param sock socket_t to destroy
86 void (*destroy
) (socket_t
*sock
);
90 * @brief socket_t constructor.
92 * currently creates one socket, listening on all addresses
95 * @param port port to bind socket to
96 * @return the created socket, or NULL on error
100 socket_t
*socket_create(u_int16_t port
);