Merge remote branch 'origin/daniel/xavp'
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 15 Feb 2010 14:47:37 +0000 (15:47 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Mon, 15 Feb 2010 14:47:37 +0000 (15:47 +0100)
* origin/daniel/xavp:
  pv: export new PV class $xavp(name)
  core: introducing xavp (eXtended AVP)
  tm: set/reset head of xavps on TM events
  pv: new pv class $xavp(...)
  core: destroy xavp list once sip msg processing is done

Conflicts:
modules/tm/h_table.c
modules/tm/t_reply.c
modules/tm/uac.c
modules_k/pv/pv.c

1  2 
modules/tm/h_table.c
modules/tm/h_table.h
modules/tm/t_hooks.c
modules/tm/t_reply.c
modules/tm/uac.c
modules_k/pv/pv.c
receive.c

@@@ -277,7 -270,9 +281,10 @@@ struct cell*  build_cell( struct sip_ms
        struct cell* new_cell;
        int          sip_msg_len;
        avp_list_t* old;
 +      struct tm_callback *cbs, *cbs_tmp;
+ #ifdef WITH_XAVP
+       sr_xavp_t** xold;
+ #endif
  
        /* allocs a new cell */
        /* if syn_branch==0 add space for md5 (MD5_LEN -sizeof(struct cell.md5)) */
Simple merge
Simple merge
@@@ -1857,7 -1838,9 +1869,10 @@@ int reply_received( struct sip_msg  *p_
        avp_list_t* backup_user_from, *backup_user_to;
        avp_list_t* backup_domain_from, *backup_domain_to;
        avp_list_t* backup_uri_from, *backup_uri_to;
+ #ifdef WITH_XAVP
+       sr_xavp_t **backup_xavps;
+ #endif
 +      int replies_locked;
  #ifdef USE_DNS_FAILOVER
        int branch_ret;
        int prev_branch;
                backup_user_to = set_avp_list(AVP_TRACK_TO | AVP_CLASS_USER, &t->user_avps_to );
                backup_domain_from = set_avp_list(AVP_TRACK_FROM | AVP_CLASS_DOMAIN, &t->domain_avps_from );
                backup_domain_to = set_avp_list(AVP_TRACK_TO | AVP_CLASS_DOMAIN, &t->domain_avps_to );
+ #ifdef WITH_XAVP
+               backup_xavps = xavp_set_list(&t->xavps_list);
+ #endif
                setbflagsval(0, uac->branch_flags);
                /* Pre- and post-script callbacks have already
 -               * been execueted by the core. (Miklos)
 +               * been executed by the core. (Miklos)
                 */
 -              if (run_top_route(onreply_rt.rlist[t->on_reply], p_msg)<0)
 -                      LOG(L_ERR, "ERROR: on_reply processing failed\n");
 +              /* lock onreply_route, for safe avp usage */
 +              LOCK_REPLIES( t );
 +              replies_locked=1;
 +              run_top_route(onreply_rt.rlist[t->on_reply], p_msg, &ctx);
 +              if ((ctx.run_flags&DROP_R_F)  && (msg_status<200)) {
 +                      if (unlikely(replies_locked)) {
 +                              replies_locked = 0;
 +                              UNLOCK_REPLIES( t );
 +                      }
 +                      goto done;
 +              }
                /* transfer current message context back to t */
                if (t->uas.request) t->uas.request->flags=p_msg->flags;
                getbflagsval(0, &uac->branch_flags);
@@@ -329,87 -312,6 +329,90 @@@ static inline int t_uac_prepare(uac_req
                goto error1;
        }
  
 +#ifdef WITH_EVENT_LOCAL_REQUEST
 +      if (unlikely(goto_on_local_req>=0)) {
 +              DBG("executing event_route[tm:local-request]\n");
 +              if(likely(build_sip_msg_from_buf(&lreq, buf, buf_len, inc_msg_no())
 +                                      == 0)) {
 +                      /* fill some field in sip_msg */
 +                      if (unlikely(set_dst_uri(&lreq, uac_r->dialog->hooks.next_hop))) {
 +                              LM_ERR("failed to set dst_uri");
 +                              free_sip_msg(&lreq);
 +                      } else {
 +                              lreq.force_send_socket = uac_r->dialog->send_sock;
 +                              lreq.rcv.proto = dst.send_sock->proto;
 +                              lreq.rcv.src_ip = dst.send_sock->address;
 +                              lreq.rcv.src_port = dst.send_sock->port_no;
 +                              lreq.rcv.dst_port = su_getport(&dst.to);
 +                              su2ip_addr(&lreq.rcv.dst_ip, &dst.to);
 +                              lreq.rcv.src_su=dst.send_sock->su;
 +                              lreq.rcv.bind_address=dst.send_sock;
 +                      #ifdef USE_COMP
 +                              lreq.rcv.comp=dst.comp;
 +                      #endif /* USE_COMP */
 +                              /* AVPs are reset anyway afterwards, so no need to 
 +                                 backup/restore them*/
 +                              sflag_bk = getsflags();
 +
 +                              /* run the route */
 +                              backup_route_type = get_route_type();
 +                              set_route_type(LOCAL_ROUTE);
 +                              /* set T to the current transaction */
 +                              backup_t=get_t();
 +                              backup_branch=get_t_branch();
 +                              backup_msgid=global_msg_id;
 +                              /* fake transaction and message id */
 +                              global_msg_id=lreq.id;
 +                              set_t(new_cell, T_BR_UNDEFINED);
 +                              run_top_route(event_rt.rlist[goto_on_local_req], &lreq, 0);
 +                              /* restore original environment */
 +                              set_t(backup_t, backup_branch);
 +                              global_msg_id=backup_msgid;
 +                              set_route_type( backup_route_type );
 +
 +                              /* restore original environment */
 +                              setsflagsval(sflag_bk);
 +
 +                              if (unlikely(lreq.new_uri.s))
 +                              {
 +                                      pkg_free(lreq.new_uri.s);
 +                                      lreq.new_uri.s=0;
 +                                      lreq.new_uri.len=0;
 +                              }
 +                              if (unlikely(lreq.dst_uri.s))
 +                              {
 +                                      pkg_free(lreq.dst_uri.s);
 +                                      lreq.dst_uri.s=0;
 +                                      lreq.dst_uri.len=0;
 +                              }
 +
 +                              if (unlikely(lreq.add_rm || lreq.body_lumps)) {
 +                                      LM_DBG("apply new updates to sip msg\n");
 +                                      buf1 = build_req_buf_from_sip_req(&lreq,
 +                                                      (unsigned int*)&buf_len1,
 +                                                      &dst, BUILD_NO_LOCAL_VIA|BUILD_NO_VIA1_UPDATE|
 +                                                      BUILD_IN_SHM);
 +                                      if (likely(buf1)){
 +                                              shm_free(buf);
 +                                              buf = buf1;
 +                                              buf_len = buf_len1;
 +                                              /* a possible change of the method is not handled! */
 +                                      }
 +                              }
 +                              lreq.buf=0; /* covers the obsolete DYN_BUF */
 +                              free_sip_msg(&lreq);
 +                      }
 +              }
 +      }
 +#endif
 +
 +      /* better reset avp list now - anyhow, it's useless from
 +       * this point (bogdan) */
 +      reset_avps();
++#ifdef WITH_XAVP
++      xavp_reset_list();
++#endif
 +
        new_cell->method.s = buf;
        new_cell->method.len = uac_r->method->len;
  
  #include "pv_shv.h"
  #include "pv_time.h"
  #include "pv_trans.h"
 +#include "pv_select.h"
+ #ifdef WITH_XAVP
+ #include "pv_xavp.h"
+ #endif
  
  MODULE_VERSION
  
@@@ -65,12 -66,11 +67,17 @@@ static pv_export_t mod_pvs[] = 
        { {"stat", sizeof("stat")-1}, /* statistics */
                PVT_OTHER, pv_get_stat, 0,
                pv_parse_stat_name, 0, 0, 0 },
 +      { {"sel", sizeof("sel")-1}, /* select */
 +              PVT_OTHER, pv_get_select, 0,
 +              pv_parse_select_name, 0, 0, 0 },
 +      {{"snd", (sizeof("snd")-1)}, PVT_OTHER, pv_get_snd, 0,
 +              pv_parse_snd_name, 0, 0, 0},
+ #ifdef WITH_XAVP
+       { {"xavp", sizeof("xavp")-1}, /* xavp */
+               PVT_OTHER, pv_get_xavp, pv_set_xavp,
+               pv_parse_xavp_name, 0, 0, 0 },
+ #endif
 +
        {{"avp", (sizeof("avp")-1)}, PVT_AVP, pv_get_avp, pv_set_avp,
                pv_parse_avp_name, pv_parse_index, 0, 0},
        {{"hdr", (sizeof("hdr")-1)}, PVT_HDR, pv_get_hdr, 0, pv_parse_hdr_name,
diff --cc receive.c
+++ b/receive.c
@@@ -291,15 -258,19 +297,21 @@@ error_rpl
        /* execute post reply-script callbacks */
        exec_post_script_cb(msg, ONREPLY_CB_TYPE);
        reset_avps();
+ #ifdef WITH_XAVP
+       xavp_reset_list();
+ #endif
        goto error02;
 +#endif /* NO_ONREPLY_ROUTE_ERROR */
  error_req:
        DBG("receive_msg: error:...\n");
        /* execute post request-script callbacks */
        exec_post_script_cb(msg, REQUEST_CB_TYPE);
 +error03:
        /* free possible loaded avps -bogdan */
        reset_avps();
+ #ifdef WITH_XAVP
+       xavp_reset_list();
+ #endif
  error02:
        free_sip_msg(msg);
        pkg_free(msg);