api_process.c

Go to the documentation of this file.
00001 
00054  #include "api_process.h"
00055  #include "transaction.h"
00056  #include "receiver.h"
00057  
00058 
00059 
00060 handler_list *handlers = 0; 
00061 gen_lock_t *handlers_lock;  
00073 int api_callback(peer *p,AAAMessage *msg,void* ptr)
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 }
00109 
00110 

Generated on Sat Sep 6 04:17:47 2008 for Open IMS Core CSCFs by  doxygen 1.5.2