Annotation of embedaddon/strongswan/src/libcharon/plugins/lookip/lookip_listener.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2012 Martin Willi
                      3:  * Copyright (C) 2012 revosec AG
                      4:  *
                      5:  * This program is free software; you can redistribute it and/or modify it
                      6:  * under the terms of the GNU General Public License as published by the
                      7:  * Free Software Foundation; either version 2 of the License, or (at your
                      8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
                      9:  *
                     10:  * This program is distributed in the hope that it will be useful, but
                     11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
                     13:  * for more details.
                     14:  */
                     15: 
                     16: /**
                     17:  * @defgroup lookip_listener lookip_listener
                     18:  * @{ @ingroup lookip
                     19:  */
                     20: 
                     21: #ifndef LOOKIP_LISTENER_H_
                     22: #define LOOKIP_LISTENER_H_
                     23: 
                     24: #include <bus/listeners/listener.h>
                     25: 
                     26: typedef struct lookip_listener_t lookip_listener_t;
                     27: 
                     28: /**
                     29:  * Callback function to query virtual IP entries
                     30:  *
                     31:  * @param user         user supplied pointer
                     32:  * @param up           TRUE if tunnels established, FALSE if closed
                     33:  * @param vip          virtual IP of remote peer
                     34:  * @param other                peer external IP
                     35:  * @param id           peer identity
                     36:  * @param name         associated connection name
                     37:  * @param unique_id    unique IKE_SA identifier
                     38:  * @return                     TRUE to receive more results, FALSE to cancel
                     39:  */
                     40: typedef bool (*lookip_callback_t)(void *user, bool up, host_t *vip,
                     41:                                                                  host_t *other, identification_t *id,
                     42:                                                                  char *name, u_int unique_id);
                     43: 
                     44: /**
                     45:  * Listener collecting virtual IPs.
                     46:  */
                     47: struct lookip_listener_t {
                     48: 
                     49:        /**
                     50:         * Implements listener_t interface.
                     51:         */
                     52:        listener_t listener;
                     53: 
                     54:        /**
                     55:         * Perform a lookup for a given virtual IP, invoke callback for matches.
                     56:         *
                     57:         * The "up" parameter is always TRUE when the callback is invoked using
                     58:         * lookup().
                     59:         *
                     60:         * @param vip           virtual IP to look up, NULL to get all entries
                     61:         * @param cb            callback function to invoke
                     62:         * @param user          user data to pass to callback function
                     63:         * @return                      number of matches
                     64:         */
                     65:        int (*lookup)(lookip_listener_t *this, host_t *vip,
                     66:                                  lookip_callback_t cb, void *user);
                     67: 
                     68:        /**
                     69:         * Register a listener function that gets notified about virtual IP changes.
                     70:         *
                     71:         * @param cb            callback function to invoke
                     72:         * @param user          user data to pass to callback function
                     73:         */
                     74:        void (*add_listener)(lookip_listener_t *this,
                     75:                                                 lookip_callback_t cb, void *user);
                     76: 
                     77:        /**
                     78:         * Unregister a listener by the user data.
                     79:         *
                     80:         * @param user          user data, as passed during add_listener()
                     81:         */
                     82:        void (*remove_listener)(lookip_listener_t *this, void *user);
                     83: 
                     84:        /**
                     85:         * Destroy a lookip_listener_t.
                     86:         */
                     87:        void (*destroy)(lookip_listener_t *this);
                     88: };
                     89: 
                     90: /**
                     91:  * Create a lookip_listener instance.
                     92:  */
                     93: lookip_listener_t *lookip_listener_create();
                     94: 
                     95: #endif /** LOOKIP_LISTENER_H_ @}*/

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