Changeset 83:c662d3eb6ff6 in freeDiameter
- Timestamp:
- Dec 2, 2009, 6:28:28 PM (14 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
freeDiameter/fD.h
r82 r83 167 167 struct fd_list p_connparams; /* The list of connection attempts, see p_cnx.c */ 168 168 }; 169 170 169 171 170 /* connection context: socket and related information */ -
include/freeDiameter/freeDiameter.h
r82 r83 427 427 428 428 /***************************************/ 429 /* Routing module */ 430 /***************************************/ 431 432 /* This file contains the definitions of types and functions involved in the routing decisions in freeDiameter, 433 * and that can be called by extensions. 434 * 435 * Three different type of messages must be distinguished: 436 * - Messages received, and the peer is final recipient (IN messages) 437 * - Messages received, and the peer is not final recipient (FWD messages) 438 * - Message is locally generated (OUT messages) 439 * 440 * There are three global message queues (in queues.c) and also peers-specific queues (in struct fd_peer). 441 * 442 * (*) IN messages processing details: 443 * - the message is received from the remote peer, a FDEVP_CNX_MSG_RECV event is generated for the peer. 444 * - the PSM thread parses the buffer, does some verifications, handles non routable messages (fd_msg_is_routable) 445 * - routable messages are queued in the fd_g_incoming global queue. 446 * - a thread (routing-in) picks the message and takes the decision if it is handled locally or forwarded, 447 * based on local capabilities (registered by extensions). 448 * - If the message is handled locally, it is queued in fd_g_local. 449 * - Another thread (dispatch.c) will handle this message and pass it to registered callbacks (see fd_disp_register in libfreeDiameter.h). 450 * 451 * (*) FWD messages details: 452 * - The process is the same as for IN messages, until the routing-in threads makes its decision that the message is not handled locally. 453 * - All callbacks registered with fd_rt_fwd_register are called for the message (see bellow). 454 * - these callbacks will typically do proxying work. Note that adding the route-record is handled by the daemon. 455 * - Once all callbacks have been called, the message is queued in the global fd_g_outgoing queue. 456 * - The remaining processing is the same as for OUT messages, as described bellow. 457 * 458 * (*) OUT messages details: 459 * - The message are picked from fd_g_outgoing, as result of forwarding process or call to fd_msg_send. 460 * - The (routing-out) thread builds a list of possible destinations for the message. 461 * The logic to build this list is as follow: 462 * - create a list of all known peers in the "OPEN" state. 463 * - remove from that list all peers that are in a Route-Record AVP of the message, to avoid routing loops. 464 * - remove also all peers that have previously replied an error message for this message. 465 * - If the list is empty, create an error UNABLE_TO_DELIVER (note: should we trig dynamic discovery here???) and reply this. 466 * - Otherwise, call all callbacks registered by function fd_rt_out_register, with the list of peers and the message. 467 * - Order the resulting list of peers by score (see bellow), and sent the message to the peer with highest (positive) score. 468 * - in case the peer is no longer in the "OPEN" state, send the message to the second peer in the list. 469 * - if no peer is in OPEN state anymore, restart the process of creating the list. 470 * - The peer thread will handle the creation of the Hop-by-hop ID and sending the message. 471 * 472 * This part of the API (routing-api.h) provides the definitions of the rt_out_cb_t and rt_fwd_cb_t callbacks, and the 473 * functions to register and deregister these callbacks. 474 */ 475 476 477 478 /***************************************/ 429 479 /* Events helpers */ 430 480 /***************************************/ 431 481 432 /* Events */433 482 struct fd_event { 434 483 int code; /* codespace depends on the queue */ … … 437 486 }; 438 487 439 /* Daemon's codespace: 1000->1999 */488 /* Daemon's codespace: 1000->1999 (1500->1999 defined in fD.h) */ 440 489 enum { 441 490 FDEV_TERMINATE = 1000 /* request to terminate */ -
include/freeDiameter/libfreeDiameter.h
r43 r83 1613 1613 1614 1614 /*============================================================*/ 1615 /* ROUTING */ 1616 /*============================================================*/ 1617 1618 /* The following functions are helpers for the routing module. 1619 The routing data is stored in the message it-self. */ 1620 1621 /* Structure that contains the routing data for a message */ 1622 struct rt_data; 1623 1624 /* Following functions are helpers to create the routing data of a message */ 1625 int fd_rtd_init(struct rt_data ** rtd); 1626 void fd_rtd_free(struct rt_data ** rtd); 1627 1628 /* Add a peer to the candidates list */ 1629 int fd_rtd_candidate_add(struct rt_data * rtd, char * peerid); 1630 1631 /* Remove a peer from the candidates (if it is found) */ 1632 void fd_rtd_candidate_del(struct rt_data * rtd, char * peerid, size_t sz /* if !0, peerid does not need to be \0 terminated */); 1633 1634 /* If a peer returned a protocol error for this message, save it so that we don't try to send it there again */ 1635 int fd_rtd_error_add(struct rt_data * rtd, char * sentto, uint8_t * origin, size_t originsz, uint32_t rcode); 1636 1637 /* Extract the list of valid candidates, and initialize their scores to 0 */ 1638 void fd_rtd_candidate_extract(struct rt_data * rtd, struct fd_list ** candidates); 1639 1640 /* The extracted list items have the following structure: */ 1641 struct rtd_candidate { 1642 struct fd_list chain; /* link in the list returned by the previous fct */ 1643 char * diamid; /* the diameter Id of the peer */ 1644 int score; /* the current routing score for this peer, see fd_rt_out_register definition for details */ 1645 }; 1646 1647 /* Reorder the list of peers */ 1648 int fd_rtd_candidate_reorder(struct fd_list * candidates); 1649 1650 1651 /*============================================================*/ 1615 1652 /* MESSAGES */ 1616 1653 /*============================================================*/ … … 1959 1996 * EINVAL: a parameter is invalid 1960 1997 */ 1961 int fd_msg_rt_associate( struct msg * msg, struct fd_list ** list);1962 int fd_msg_rt_get ( struct msg * msg, struct fd_list ** list);1998 int fd_msg_rt_associate( struct msg * msg, struct rt_data ** rtd ); 1999 int fd_msg_rt_get ( struct msg * msg, struct rt_data ** rtd ); 1963 2000 1964 2001 /* -
libfreeDiameter/CMakeLists.txt
r10 r83 12 12 log.c 13 13 messages.c 14 rt_data.c 14 15 sessions.c 15 16 ) -
libfreeDiameter/lists.c
r25 r83 87 87 senti->prev = senti; 88 88 senti->next = senti; 89 90 89 } 91 90 -
libfreeDiameter/messages.c
r37 r83 118 118 int msg_routable; /* Is this a routable message? (0: undef, 1: routable, 2: non routable) */ 119 119 struct msg *msg_query; /* the associated query if the message is a received answer */ 120 struct fd_list *msg_rtlist; /* Routing list for the query */120 struct rt_data *msg_rtdata; /* Routing list for the query */ 121 121 struct { 122 122 void (*fct)(void *, struct msg **); … … 569 569 } 570 570 571 if ((obj->type == MSG_MSG) && (_M(obj)->msg_rtlist != NULL)) { 572 while (! FD_IS_LIST_EMPTY(_M(obj)->msg_rtlist) ) { 573 struct fd_list * li = _M(obj)->msg_rtlist->next; 574 fd_list_unlink(li); 575 free(li); 576 } 577 578 free(_M(obj)->msg_rtlist); 571 if ((obj->type == MSG_MSG) && (_M(obj)->msg_rtdata != NULL)) { 572 fd_rtd_free(&_M(obj)->msg_rtdata); 579 573 } 580 574 … … 1031 1025 1032 1026 /* Associate routing lists */ 1033 int fd_msg_rt_associate( struct msg * msg, struct fd_list ** list)1034 { 1035 TRACE_ENTRY( "%p %p", msg, list);1036 1037 CHECK_PARAMS( CHECK_MSG(msg) && list);1038 1039 msg->msg_rt list = *list;1040 * list= NULL;1041 1042 return 0; 1043 } 1044 1045 int fd_msg_rt_get( struct msg * msg, struct fd_list ** list)1046 { 1047 TRACE_ENTRY( "%p %p", msg, list);1048 1049 CHECK_PARAMS( CHECK_MSG(msg) && list);1050 1051 * list = msg->msg_rtlist;1052 msg->msg_rt list= NULL;1027 int fd_msg_rt_associate( struct msg * msg, struct rt_data ** rtd ) 1028 { 1029 TRACE_ENTRY( "%p %p", msg, rtd ); 1030 1031 CHECK_PARAMS( CHECK_MSG(msg) && rtd ); 1032 1033 msg->msg_rtdata = *rtd; 1034 *rtd = NULL; 1035 1036 return 0; 1037 } 1038 1039 int fd_msg_rt_get( struct msg * msg, struct rt_data ** rtd ) 1040 { 1041 TRACE_ENTRY( "%p %p", msg, rtd ); 1042 1043 CHECK_PARAMS( CHECK_MSG(msg) && rtd ); 1044 1045 *rtd = msg->msg_rtdata; 1046 msg->msg_rtdata = NULL; 1053 1047 1054 1048 return 0;
Note: See TracChangeset
for help on using the changeset viewer.