Navigation



Ignore:
Timestamp:
Sep 25, 2009, 6:05:06 PM (15 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Added some support for peers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/freeDiameter.h

    r10 r11  
    160160        STATE_REOPEN            /* Connection has been re-established, waiting for 3 DWR/DWA exchanges before putting back to service */
    161161};
    162 extern char *peer_state_str[];
     162extern const char *peer_state_str[];
    163163
    164164/* Information about a remote peer, used both for query and for creating a new entry */
     
    214214};
    215215
     216struct peer_hdr {
     217        struct fd_list   chain; /* List of all the peers, ordered by their Diameter Id */
     218        struct peer_info info;  /* The public data */
     219       
     220        /* This header is followed by more data in the private peer structure definition */
     221};
     222
     223/* the global list of peers.
     224  Since we are not expecting so many connections, we don't use a hash, but it might be changed.
     225  The list items are peer_hdr structures (actually, fd_peer, but the cast is OK) */
     226extern struct fd_list fd_g_peers;
     227extern pthread_rwlock_t fd_g_peers_rw; /* protect the list */
     228
     229/*
     230 * FUNCTION:    fd_peer_add
     231 *
     232 * PARAMETERS:
     233 *  info        : Information to create the peer.
     234 *  cb          : optional, a callback to call (once) when the peer connection is established or failed
     235 *  cb_data     : opaque data to pass to the callback.
     236 *
     237 * DESCRIPTION:
     238 *  Add a peer to the list of peers to which the daemon must maintain a connexion.
     239 * If cb is not null, the callback is called when the connection is in OPEN state or
     240 * when an error has occurred. The callback should use the pi_state information to
     241 * determine which one it is.
     242 *
     243 * RETURN VALUE:
     244 *  0           : The peer is added.
     245 *  EINVAL      : A parameter is invalid.
     246 *  EEXIST      : A peer with the same Diameter-Id is already in the list.
     247 *  (other standard errors may be returned, too, with their standard meaning. Example:
     248 *    ENOMEM    : Memory allocation for the new object element failed.)
     249 */
     250int fd_peer_add ( struct peer_info * info, void (*cb)(struct peer_info *, void *), void * cb_data );
     251
     252/*
     253 * FUNCTION:    peer_validate_register
     254 *
     255 * PARAMETERS:
     256 *  peer_validate       : Callback as defined bellow.
     257 *
     258 * DESCRIPTION:
     259 *  Add a callback to authorize / reject incoming peer connections.
     260 * All registered callbacks are called until a callback sets auth = -1 or auth = 1.
     261 * If no callback returns a clear decision, the default behavior is applied (reject unknown connections)
     262 *
     263 * RETURN VALUE:
     264 *  0   : The callback is added.
     265 * !0   : An error occurred.
     266 */
     267int fd_peer_validate_register ( int (*peer_validate)(struct peer_info * /* info */, int * /* auth */) );
     268/*
     269 * CALLBACK:    peer_validate
     270 *
     271 * PARAMETERS:
     272 *   info     : Structure containing information about the peer attempting the connection.
     273 *   auth     : Store there the result if the peer is accepted (1), rejected (-1), or unknown (0).
     274 *
     275 * DESCRIPTION:
     276 *   This callback is called when a new connection is being established from an unknown peer,
     277 *  after the CER is received. An extension must register such callback with peer_validate_register.
     278 *
     279 * RETURN VALUE:
     280 *  0           : The authorization decision has been written in the location pointed by auth.
     281 *  !0          : An error occurred.
     282 */
    216283
    217284/***************************************/
Note: See TracChangeset for help on using the changeset viewer.