Navigation


Changeset 1103:d8591b1c56cd in freeDiameter for include


Ignore:
Timestamp:
May 10, 2013, 7:48:57 PM (11 years ago)
Author:
Sebastien Decugis <sdecugis@freediameter.net>
Branch:
default
Phase:
public
Message:

Implemented a few hooks

Location:
include/freeDiameter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/freeDiameter/libfdcore.h

    r1102 r1103  
    553553
    554554
    555 /* Parse a message against our dictionary, and in case of error log and eventually build the error reply (on return and EBADMSG, *msg == NULL or *msg is the error message ready to send) */
    556 int fd_msg_parse_or_error( struct msg ** msg );
     555/* Parse a message against our dictionary,
     556        return 0 in case of success.
     557        log parsing error & return error code in case of failure in parsing.
     558        In addition, if the error code is EBADMSG (the message does not follow our dictionary)
     559                if *msg was a request, *msg is NULL and *error contains the error message ready to send back on return
     560                if *msg was an answer, *msg is untouched and *error==*msg if *msg was an error message, *error is null otherwise */
     561int fd_msg_parse_or_error( struct msg ** msg, struct msg **error );
    557562
    558563
     
    926931                 - {peer} is set if the message is received from a peer's connection, and NULL if the message is from a new client
    927932                   connected and not yet identified
    928                  - {other} is NULL.
     933                 - {other} is NULL, or a char * identifying the connection when {peer} is null.
    929934                 - {permsgdata} points to either a new empty structure allocated for this message or the one passed to HOOK_DATA_RECEIVED if used.
    930935                 */
     
    959964                 */
    960965       
     966        HOOK_MESSAGE_PARSING_ERROR,
     967                /* Hook called when a message being processed cannot be parsed successfully.
     968                 - {msg} points to the message if buffer was parsed successfully, or NULL otherwise. You should not call fd_msg_parse_dict on this in any case.
     969                 - {peer} is NULL or the peer that received the message. If NULL and the message is not NULL, you can still retrieve the source from the message itself.
     970                 - {other} is a char * pointer to the error message (human-readable) if {msg} is not NULL, a pointer to struct fd_cnx_rcvdata containing the received buffer otherwise.
     971                 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
     972                 */
     973       
    961974        HOOK_MESSAGE_ROUTING_ERROR,
    962                 /* Hook called when a message being processed by the routing thread meets an error such as:
    963                      -- parsing error
    964                      -- no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
     975                /* Hook called when a message being processed by the routing thread meets an error such as no remaining available peer for sending, based on routing callbacks decisions (maybe after retries).
    965976                 - {msg} points to the message. Again, the objects may not have been dictionary resolved. If you
    966977                   try to call fd_msg_parse_dict, it might slow down the operation of a relay agent, although this hook is not on the normal execution path.
     
    9941005                   It is probably a good idea to log this for analysis / backup.
    9951006                 - {msg} points to the message, which will be freed as soon as the hook returns.
    996                  - {peer} is NULL.
     1007                 - {peer} may be NULL or a peer related to the event.
    9971008                 - {other} is a char * pointer to the error message (human-readable).
    9981009                 - {permsgdata} points to existing structure associated with this message (or new structure if no previous hook was registered).
     
    10001011       
    10011012        HOOK_PEER_CONNECT_FAILED,
    1002                 /* Hook called when a connection attempt to a remote peer has failed.
    1003                  - {msg} may be NULL (lower layer error, e.g. connection timeout) or points to the CEA message sent or received (with an error code).
     1013                /* Hook called when a connection attempt to/from a remote peer has failed. This hook is also called when the peer was in OPEN state and the connection is broken.
     1014                 - {msg} may be NULL (lower layer error, e.g. connection timeout) or points to a message showing the error (either invalid incoming message, or the CEA message sent or received with an error code).
    10041015                 - {peer} may be NULL for incoming requests from unknown peers being rejected, otherwise it points to the peer structure associated with the attempt.
    10051016                 - {other} is a char * pointer to the error message (human-readable).
     
    10081019       
    10091020        HOOK_PEER_CONNECT_SUCCESS,
    1010                 /* Hook called when a connection attempt to a remote peer has succeeded (the peer moves to OPEN state).
    1011                  - {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.
     1021                /* Hook called when a connection attempt to/from a remote peer has succeeded (the peer moves to OPEN_HANDSHAKE or OPEN state).
     1022                    In case of deprecated TLS handshake after the CER/CEA exchange, this hook can still be followed by HOOK_PEER_CONNECT_FAILED if TLS handshake fails.
     1023                 - {msg} points to the CEA message sent or received (with a success code) -- in case it is sent, you can always get access to the matching CER.
    10121024                 - {peer} points to the peer structure.
    10131025                 - {other} is NULL.
     
    10691081 *
    10701082 * PARAMETERS:
    1071  *  type_mask     : A bitmask of fd_hook_type bits for which this cb is registered, e.g. ((1 << HOOK_MESSAGE_RECEIVED) || (1 << HOOK_MESSAGE_SENT))
     1083 *  type_mask     : A bitmask of fd_hook_type bits for which this cb is registered, e.g. ((1 << HOOK_MESSAGE_RECEIVED) | (1 << HOOK_MESSAGE_SENT))
    10721084 *  fd_hook_cb    : The callback function to register (see prototype above).
    10731085 *  regdata       : Pointer to pass to the callback when it is called. The data is opaque to the daemon.
     
    10931105/* Remove a hook registration */
    10941106int fd_hook_unregister( struct fd_hook_hdl * handler );
     1107
     1108
     1109/* Use the following function to retrieve any pmd structure associated with a request matching the current answer. Returns NULL in case of error / no such structure */
     1110struct fd_hook_permsgdata * fd_hook_get_request_pmd(struct fd_hook_data_hdl *data_hdl, struct msg * answer);
    10951111
    10961112
  • include/freeDiameter/libfdproto.h

    r1102 r1103  
    146146 */
    147147void fd_log ( int, const char *, ... ) _ATTRIBUTE_PRINTFLIKE_(2,3);
     148#ifndef SWIG
    148149void fd_log_va( int, const char *, va_list args );
     150#endif /* SWIG */
    149151
    150152/* these are internal objects of the debug facility,
     
    609611DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump_node, sSA * sa, int flags);
    610612DECLARE_FD_DUMP_PROTOTYPE(fd_sa_dump_node_serv, sSA * sa, int flags);
     613#define sSA_DUMP_STRLEN (INET6_ADDRSTRLEN + 1 + 32 + 2)
     614void fd_sa_sdump_numeric(char * buf /* must be at least sSA_DUMP_STRLEN */, sSA * sa);
    611615
    612616
Note: See TracChangeset for help on using the changeset viewer.