Navigation


Changes in / [1066:a455dbb7527c:1065:c4e4e07f1336] in freeDiameter


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdcore.h

    r1063 r1014  
    855855int fd_app_empty(struct fd_list * list);
    856856
    857 
    858 
    859 /*============================================================*/
    860 /*                         MONITORING                         */
    861 /*============================================================*/
    862 
    863 /* These functions allows an extension to collect state information about the
    864  * framework state, as well as hooks at some key checkpoints in the processing
    865  * for logging / statistics purpose.
    866  */
    867  
    868 
    869 /* CALLBACK:    fd_hook_cb
    870  *
    871  * PARAMETERS:
    872  *  type        : The type of hook that triggered this call, in case same cb is registered for several hooks.
    873  *  msg         : If relevant, the pointer to the message trigging the call. NULL otherwise.
    874  *  peer        : If relevant, the pointer to the peer associated with the call. NULL otherwise.
    875  *  other       : For some callbacks, the remaining information is passed in this parameter. See each hook detail.
    876  *  regdata     : Data pointer stored at registration, opaque for the framework.
    877  *
    878  * DESCRIPTION:
    879  *   When such callback is registered with fd_hook_register function, it will be called on matching events with
    880  * the parameters as described in the list of fd_hook_type below. One can use this mechanism for e.g.:
    881  *  - log completely the messages for safety / backup
    882  *  - create statistics information on the throughput
    883  *  - ...
    884  *
    885  *  IMPORTANT: the callback MUST NOT change the momory pointed by the different parameters (peer, message, ...)
    886  *
    887  * RETURN VALUE:
    888  *  none.
    889  */
    890  
    891 /* The available hooks in the framework */
    892 enum fd_hook_type {
    893 
    894         HOOK_MESSAGE_RECEIVED = 1,
    895                 /* Hook called when a message has been received and the structure has been parsed successfully (list of AVPs).
    896                  - *msg points to the parsed message. At this time, the objects have not been dictionary resolved. If you
    897                    try to call fd_msg_parse_dict, it might slow down the operation of a relay agent.
    898                  - *peer is set if the message is received from a peer's connection, and NULL if the message is from a new client
    899                    connected and not yet identified
    900                  - *other is NULL.
    901                  */
    902        
    903         /* HOOK_DATA_RECEIVED, <-- this one is tricky to implement, will skip in the first version */
    904                 /* Hook called as soon as data is received from a socket.
    905                  - *msg is NULL.
    906                  - *peer is set if the data is received from a peer's connection, and NULL if the message is from a new client
    907                    connected and not yet identified
    908                  - *other points to a structure: { .
    909                  */
    910                  
    911         HOOK_MESSAGE_SENT,
    912                 /* Hook called when a message has been sent to a peer. The message might be freed as soon as the hook function returns,
    913                    so it is not safe to store the pointer for asynchronous processing.
    914                  - *msg points to the sent message. Again, the objects may not have been dictionary resolved. If you
    915                    try to call fd_msg_parse_dict, it might slow down the operation of a relay agent.
    916                  - *peer is set if the message is sent to a peer's connection, and NULL if the message is sent to a new client
    917                    connected and not yet identified / being rejected
    918                  - *other is NULL.
    919                  */
    920        
    921         HOOK_MESSAGE_ROUTING_ERROR,
    922                 /* Hook called when a message being processed by the routing thread meets an error such as:
    923                      -- parsing error
    924                      -- no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
    925                  - *msg points to the message. Again, the objects may not have been dictionary resolved. If you
    926                    try to call fd_msg_parse_dict, it might slow down the operation of a relay agent.
    927                  - *peer is NULL.
    928                  - *other is a char * pointer to the error message (human-readable).
    929                  */
    930        
    931         HOOK_MESSAGE_ROUTING_FORWARD,
    932                 /* Hook called when a received message is deemed to be not handled locally by the routing_dispatch process.
    933                    The decision of knowing which peer it will be sent to is not made yet (or if an error will be returned).
    934                    The hook is trigged before the callbacks registered with fd_rt_fwd_register are called.
    935                  - *msg points to the message. Again, the objects may not have been dictionary resolved. If you
    936                    try to call fd_msg_parse_dict, it might slow down the operation of a relay agent.
    937                  - *peer is NULL.
    938                  - *other is NULL.
    939                  */
    940        
    941         HOOK_MESSAGE_ROUTING_LOCAL,
    942                 /* Hook called when a received message is handled locally by the routing_dispatch process.
    943                    The hook is trigged before the callbacks registered with fd_disp_register are called.
    944                  - *msg points to the message. Here, the message has been already parsed completely & successfully.
    945                  - *peer is NULL.
    946                  - *other is NULL.
    947                  */
    948        
    949         HOOK_MESSAGE_DROPPED,
    950                 /* Hook called when a message is being discarded by the framework because of some error.
    951                    It is probably a good idea to log this for analysis.
    952                  - *msg points to the message.
    953                  - *peer is NULL.
    954                  - *other is a char * pointer to the error message (human-readable).
    955                  */
    956        
    957         HOOK_PEER_CONNECT_FAILED,
    958                 /* Hook called when a connection attempt to a remote peer has failed.
    959                  - *msg may be NULL (lower layer error, e.g. connection timeout) or points to the CEA message sent or received (with an error code).
    960                  - *peer may be NULL for incoming requests from unknown peers being rejected, otherwise it points to the peer structure associated with the attempt.
    961                  - *other is a char * pointer to the error message (human-readable).
    962                  */
    963        
    964         HOOK_PEER_CONNECT_SUCCESS,
    965                 /* Hook called when a connection attempt to a remote peer has succeeded (the peer moves to OPEN state).
    966                  - *msg points to the CEA message sent or received (with an success code) -- in case it is sent, you can always get access to the matching CER.
    967                  - *peer points to the peer structure.
    968                  - *other is NULL.
    969                  */
    970        
    971 };
    972        
    973 /* A handler associated with a registered callback, for cleanup */
    974 struct fd_hook_hdl;
    975 
    976 /*
    977  * FUNCTION:    fd_hook_register
    978  *
    979  * PARAMETERS:
    980  *  type          : The fd_hook_type for which this cb is registered. Call several times if you want to register for several hooks.
    981  *  fd_hook_cb    : The callback function to register (see prototype above).
    982  *  regdata       : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
    983  *  handler       : On success, a handler to the registered callback is stored here.
    984  *                 This handler will be used to unregister the cb.
    985  *
    986  * DESCRIPTION:
    987  *   Register a new hookin the framework. See explanations above.
    988  *
    989  * RETURN VALUE:
    990  *  0           : The callback is registered.
    991  *  EINVAL      : A parameter is invalid.
    992  *  ENOMEM      : Not enough memory to complete the operation
    993  */
    994 int fd_hook_register (  enum fd_hook_type type,
    995                         void (*fd_hook_cb)(enum fd_hook_type type, struct msg * msg, struct peer_hdr * peer, void * other, void * regdata),
    996                         void * regdata, struct fd_hook_hdl ** handler );
    997 
    998 /* Remove a hook registration */
    999 int fd_hook_unregister( struct fd_hook_hdl * handler );
    1000 
    1001 
    1002 
    1003 /*
    1004  * The following allows an extension to retrieve stat information on the different fifo queues involved in the freeDiameter framework.
    1005  * There are three global queues, plus per-peer queues.
    1006  * This information can be used to build SNMP-like data for example, or quickly get a status of the framework to find the loaded path of execution / bottlenecks.
    1007  */
    1008 enum fd_stat_type {
    1009         /* For the following, no peer is associated with the stat */
    1010         STAT_G_LOCAL= 1,        /* Get statistics for the global queue of messages processed by local extensions */
    1011         STAT_G_INCOMING,        /* Get statistics for the global queue of received messages to be processed by routing_in thread */
    1012         STAT_G_OUTGOING,        /* Get statistics for the global queue of messages to be processed by routing_out thread */
    1013        
    1014         /* For the following, the peer must be provided */
    1015         STAT_P_PSM,             /* Peer state machine queue (events to be processed for this peer, including received messages) */
    1016         STAT_P_TOSEND,          /* Queue of messages for sending to this peer */
    1017 };
    1018 
    1019 /*
    1020  * FUNCTION:    fd_stat_getstats
    1021  *
    1022  * PARAMETERS:
    1023  *  stat          : Which queue is being queried
    1024  *  peer          : (depending on the stat parameter) which peer is being queried
    1025  *  len           : (out) The number of items in the queue currently
    1026  *  max           : (out) The max number of items the queue accepts before becoming blocking -- 0 means no max.
    1027  *  highest_count : (out) The highest count the queue has reached since startup
    1028  *  total         : (out) Cumulated time all items spent in this queue, including blocking time (always growing, use deltas for monitoring)
    1029  *  blocking      : (out) Cumulated time threads trying to post new items were blocked (queue full).
    1030  *  last          : (out) For the last element retrieved from the queue, how long it took between posting (including blocking) and poping
    1031  * 
    1032  * DESCRIPTION:
    1033  *   Get statistics information about a given queue.
    1034  *  Any of the (out) parameters can be NULL if not requested.
    1035  *
    1036  * RETURN VALUE:
    1037  *  0           : The callback is registered.
    1038  *  EINVAL      : A parameter is invalid.
    1039  */
    1040 int fd_stat_getstats(enum fd_stat_type stat, struct peer_hdr * peer,
    1041                         int * len, int * max, int * highest_count,
    1042                         struct timespec * total, struct timespec * blocking, struct timespec * last);
    1043 
    1044857#ifdef __cplusplus
    1045858}
Note: See TracChangeset for help on using the changeset viewer.