Annotation of embedaddon/strongswan/src/libcharon/network/socket_manager.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * Copyright (C) 2010-2013 Tobias Brunner
        !             3:  * HSR Hochschule fuer Technik Rapperswil
        !             4:  * Copyright (C) 2010 Martin Willi
        !             5:  * Copyright (C) 2010 revosec AG
        !             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: 
        !            28: typedef struct socket_manager_t socket_manager_t;
        !            29: 
        !            30: /**
        !            31:  * Handle pluggable socket implementations and send/receive packets through it.
        !            32:  */
        !            33: struct 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:         */
        !            43:        status_t (*receive)(socket_manager_t *this, packet_t **packet);
        !            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:         */
        !            53:        status_t (*send)(socket_manager_t *this, packet_t *packet);
        !            54: 
        !            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:         */
        !            61:        uint16_t (*get_port)(socket_manager_t *this, bool nat_t);
        !            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);
        !            69: 
        !            70:        /**
        !            71:         * Register a socket constructor.
        !            72:         *
        !            73:         * @param create                constructor for the socket
        !            74:         */
        !            75:        void (*add_socket)(socket_manager_t *this, socket_constructor_t create);
        !            76: 
        !            77:        /**
        !            78:         * Unregister a registered socket constructor.
        !            79:         *
        !            80:         * @param create                constructor for the socket
        !            81:         */
        !            82:        void (*remove_socket)(socket_manager_t *this, socket_constructor_t create);
        !            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:  */
        !            93: socket_manager_t *socket_manager_create();
        !            94: 
        !            95: #endif /** SOCKET_MANAGER_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>