Navigation


Changeset 11:6576ef5e01eb in freeDiameter


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

Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • extensions/dbg_monitor/monitor.c

    r10 r11  
    7171        /* Loop */
    7272        while (1) {
    73                 sleep(60);
     73                #ifdef DEBUG
     74                sleep(30);
     75                #else /* DEBUG */
     76                sleep(3600); /* 1 hour */
     77                #endif /* DEBUG */
    7478                TRACE_DEBUG(NONE, "Monitor information");
    7579                CHECK_FCT_DO(fd_event_send(fd_g_config->cnf_main_ev, FDEV_DUMP_QUEUES, NULL), /* continue */);
  • freeDiameter/CMakeLists.txt

    r10 r11  
    1515        dict_base_proto.c
    1616        messages.c
     17        peers.c
    1718        queues.c
    1819        )
  • freeDiameter/fD.h

    r10 r11  
    6969int fd_dict_base_protocol(struct dictionary * dict);
    7070
     71/* Peers */
     72struct fd_peer { /* The "real" definition of the peer structure */
     73       
     74        struct peer_hdr p_hdr; /* contains all public data */
     75       
     76        int             p_eyec; /* Eye catcher, EYEC_PEER */
     77        #define EYEC_PEER       0x373C9336
     78       
     79        /* threads, message queues, socket & callbacks */
     80       
     81};
     82
     83int fd_peer_init();
     84void fd_peer_dump(int details);
     85int fd_peer_start();
     86int fd_peer_waitstart();
     87
    7188#endif /* _FD_H */
  • freeDiameter/main.c

    r10 r11  
    8080        CHECK_FCT(  fd_queues_init()  );
    8181        CHECK_FCT(  fd_msg_init()  );
     82        CHECK_FCT(  fd_peer_init()  );
    8283       
    8384        /* Parse the configuration file */
     
    8889       
    8990        /* Start the peer state machines */
    90        
     91        CHECK_FCT( fd_peer_start() );
    9192       
    9293        /* Now, just wait for events */
     
    115116                                break;
    116117                       
     118                        case FDEV_DUMP_PEERS:
     119                                fd_peer_dump(FULL);
     120                                break;
    117121                       
    118122                        case FDEV_TERMINATE:
  • 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/***************************************/
  • libfreeDiameter/fifo.c

    r10 r11  
    117117       
    118118        CHECK_POSIX_DO(  pthread_mutex_lock( &queue->mtx ), /* continue */  );
    119         fd_log_debug("  %d elements in queue\n", queue->count);
    120         fd_log_debug("  %d threads waiting\n", queue->thrs);
    121         fd_log_debug("  thresholds: %d / %d, cb: %p / %p (%p), highest: %d\n",
     119        fd_log_debug("   %d elements in queue / %d threads waiting\n", queue->count, queue->thrs);
     120        fd_log_debug("   thresholds: %d / %d, cb: %p / %p (%p), highest: %d\n",
    122121                        queue->high, queue->low,
    123122                        queue->h_cb, queue->l_cb, queue->data,
Note: See TracChangeset for help on using the changeset viewer.