Changeset 1014:908ffbb81f60 in freeDiameter for include
- Timestamp:
- Mar 29, 2013, 6:30:59 PM (11 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- include/freeDiameter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
include/freeDiameter/libfdcore.h
r1010 r1014 463 463 * PARAMETERS: 464 464 * pmsg : Location of the message to be sent on the network (set to NULL on function return to avoid double deletion). 465 * anscb : A callback to be called when answer is received, if msg is a request (optional for fd_msg_send) 466 * anscb_data : opaque data to be passed back to the anscb when it is called. 465 * anscb : A callback to be called when corresponding answer is received, when sending a request (not used with answers) 466 * anscb_data : opaque data to be passed back to the anscb (or expirecb) when it is called. 467 * expirecb : (only for fd_msg_send_timeout) If the request did not get an answer before timeout, this callback is called. 467 468 * timeout : (only for fd_msg_send_timeout) sets the absolute time until when to wait for an answer. Past this time, 468 * the anscb is called with the request as parameter and the answer will be discarded when received.469 * the expirecb is called with the request and the answer will be discarded if received later. 469 470 * 470 471 * DESCRIPTION: 471 472 * Sends a message on the network. (actually simply queues it in a global queue, to be picked by a daemon's thread) 472 473 * For requests, the end-to-end id must be set (see fd_msg_get_eteid / MSGFL_ALLOC_ETEID). 473 * For answers, the message must be created with function fd_msg_new_answ .474 * For answers, the message must be created with function fd_msg_new_answer_from_req. 474 475 * 475 476 * The routing module will handle sending to the correct peer, usually based on the Destination-Realm / Destination-Host AVP. … … 477 478 * If the msg is a request, there are two ways of receiving the answer: 478 479 * - either having registered a callback in the dispatch module (see fd_disp_register) 479 * - or provide a callback as parameterhere. If such callback is provided, it is called before the dispatch callbacks.480 * The prototype for this callback function is:480 * - or provide a anscb callback here. If such callback is provided, it is called before the dispatch callbacks. 481 * The prototype for this anscb callback function is: 481 482 * void anscb(void * data, struct msg ** answer) 482 483 * where: … … 489 490 * If no callback is registered to handle an answer, the message is discarded and an error is logged. 490 491 * 491 * fd_msg_send_timeout is similar to fd_msg_send, except that it takes an additional argument "timeout" and can be called 492 * only with requests as parameters, and an anscb callback. 493 * If the matching answer or error is received before the timeout date passes, everything occurs as with fd_msg_send. Otherwise, 494 * the request is removed from the queue (meaning the matching answer will be discarded upon reception) and passed to the answcb 495 * function. This function can easily distinguish between timeout case and answer case by checking if the message received is 496 * a request. Upon return, if the *msg parameter is not NULL, it is freed (not passed to other callbacks). 492 * fd_msg_send_timeout is similar to fd_msg_send, except that it takes two additional arguments "expirecb" and "timeout". 493 * If the message parameter is an answer, there is no difference with fd_msg_send. 494 * Otherwise, if the corresponding answer (or error) is received before the timeout date elapses, everything occurs as with fd_msg_send. 495 * Otherwise, the request is removed from the queue (meaning the matching answer will be discarded upon reception) and passed to the expirecb 496 * function. Upon return, if the *msg parameter is not NULL, it is freed (not passed to other callbacks). 497 * expirecb is called in a dedicated thread. 498 * 499 * The prototype for the expirecb callback function is: 500 * void expirecb(void * data, struct peer_hdr * sentto, struct msg ** request) 501 * where: 502 * data : opaque data that was registered along with the callback. 503 * sentto : pointer to the peer to which the message was sent and no answer received within timeout. 504 * request: location of the pointer to the request that was not answered. 497 505 * 498 506 * RETURN VALUE: … … 502 510 */ 503 511 int fd_msg_send ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data ); 504 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, const struct timespec *timeout );512 int fd_msg_send_timeout ( struct msg ** pmsg, void (*anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ); 505 513 506 514 /* -
include/freeDiameter/libfdproto.h
r1004 r1014 2427 2427 * 2428 2428 * PARAMETERS: 2429 * msg : the answermessage2429 * msg : the request message 2430 2430 * anscb : the callback to associate with the message 2431 2431 * data : the data to pass to the callback 2432 * expirecb : the expiration callback to associate with the message 2432 2433 * timeout : (optional, use NULL if no timeout) a timeout associated with calling the cb. 2433 2434 * 2434 2435 * DESCRIPTION: 2435 * Associate or retrieve a callback with an answermessage.2436 * Associate or retrieve callbacks with an message. 2436 2437 * This is meant to be called from the daemon only. 2437 2438 * … … 2440 2441 * EINVAL: a parameter is invalid 2441 2442 */ 2442 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data, const struct timespec *timeout );2443 int fd_msg_anscb_get ( struct msg * msg, void (**anscb)(void *, struct msg **), void ** data );2443 int fd_msg_anscb_associate( struct msg * msg, void ( *anscb)(void *, struct msg **), void * data, void (*expirecb)(void *, DiamId_t, size_t, struct msg **), const struct timespec *timeout ); 2444 int fd_msg_anscb_get( struct msg * msg, void (**anscb)(void *, struct msg **), void (**expirecb)(void *, DiamId_t, size_t, struct msg **), void ** data ); 2444 2445 struct timespec *fd_msg_anscb_gettimeout( struct msg * msg ); /* returns NULL or a valid non-0 timespec */ 2445 2446
Note: See TracChangeset
for help on using the changeset viewer.