api_process.h File Reference


Detailed Description

CDiameterPeer API processor.

Author:
Dragos Vingarzan vingarzan -at- fokus dot fraunhofer dot de

Definition in file api_process.h.

#include "peer.h"
#include "diameter.h"

Go to the source code of this file.

Data Structures

struct  handler_t
 Diameter message received handler list element. More...
struct  handler_list_t

Typedefs

typedef handler_t handler
 Diameter message received handler list element.
typedef handler_list_t handler_list

Enumerations

enum  handler_types { REQUEST_HANDLER = 0, RESPONSE_HANDLER = 1 }
 Request types for handler switching. More...

Functions

int api_callback (peer *p, AAAMessage *msg, void *ptr)
 This callback is added as an internal message listener and used to process transaction requests.


Typedef Documentation

typedef struct handler_t handler

Diameter message received handler list element.

typedef struct handler_list_t handler_list


Enumeration Type Documentation

enum handler_types

Request types for handler switching.

Enumerator:
REQUEST_HANDLER  the message received is a request
RESPONSE_HANDLER  the message received is a response

Definition at line 64 of file api_process.h.

00064                    {
00065     REQUEST_HANDLER=0,  
00066     RESPONSE_HANDLER=1  
00067 };


Function Documentation

int api_callback ( peer p,
AAAMessage msg,
void *  ptr 
)

This callback is added as an internal message listener and used to process transaction requests.

Definition at line 73 of file api_process.c.

References _cdp_trans_t::ans, _cdp_trans_t::auto_drop, _cdp_trans_t::cb, free_trans(), handler_t::handler, handlers, handlers_lock, handler_list_t::head, is_req, handler_t::next, handler_t::param, peer_send_msg(), _cdp_trans_t::ptr, REQUEST_HANDLER, handler_t::requestHandler, RESPONSE_HANDLER, handler_t::responseHandler, take_trans(), and handler_t::type.

Referenced by diameter_peer_init().

00074 {
00075     cdp_trans_t *t;
00076     int auto_drop;  
00077     handler *h;
00078     enum handler_types type;
00079     AAAMessage *rsp;
00080     if (is_req(msg)) type = REQUEST_HANDLER;
00081     else type=RESPONSE_HANDLER;
00082 
00083     lock_get(handlers_lock);
00084         for(h=handlers->head;h;h=h->next){
00085             if (h->type==type){
00086                 if (h->type == REQUEST_HANDLER) {                   
00087                     rsp = (h->handler.requestHandler)(msg,h->param);
00088                     if (rsp) peer_send_msg(p,rsp);
00089                 }
00090                 else (h->handler.responseHandler)(msg,h->param);
00091             }
00092         }       
00093     lock_release(handlers_lock);
00094     
00095     if (!is_req(msg)){      
00096         /* take care of transactional callback if any */
00097         t = take_trans(msg);
00098         if (t){
00099             t->ans = msg;
00100             auto_drop = t->auto_drop;
00101             if (t->cb){
00102                 (t->cb)(0,*(t->ptr),msg);
00103             }
00104             if (auto_drop) free_trans(t);
00105         }
00106     }
00107     return 1;
00108 }


Generated on Tue Jul 29 04:19:13 2008 for Open IMS Core CSCFs by  doxygen 1.5.2