cpl_sig.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "../../action.h"
00025 #include "../../dset.h"
00026 #include "../tm/tm_load.h"
00027 #include "loc_set.h"
00028 #include "cpl_sig.h"
00029 #include "cpl_env.h"
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
00040 unsigned char flag)
00041 {
00042 struct location *foo;
00043 struct action act;
00044 int bflags;
00045
00046 if (!*locs) {
00047 LM_ERR("empty loc set!!\n");
00048 goto error;
00049 }
00050
00051
00052
00053 if (!(flag&CPL_PROXY_DONE)) {
00054 LM_DBG("rewriting Request-URI with <%s>\n",(*locs)->addr.uri.s);
00055
00056 act.type = SET_URI_T;
00057 act.elem[0].type = STRING_ST;
00058 act.elem[0].u.string = (*locs)->addr.uri.s;
00059 act.next = 0;
00060
00061 if (do_action(&act, msg) < 0) {
00062 LM_ERR("do_action failed\n");
00063 goto error;
00064 }
00065
00066 if((*locs)->addr.received.s && (*locs)->addr.received.len) {
00067 LM_DBG("rewriting Destination URI "
00068 "with <%s>\n",(*locs)->addr.received.s);
00069 act.type = SET_DSTURI_T;
00070 act.elem[0].type = STRING_ST;
00071 act.elem[0].u.s = (*locs)->addr.received;
00072 act.next = 0;
00073
00074 if (do_action(&act, msg) < 0) {
00075 LM_ERR("do_action failed\n");
00076 goto error;
00077 }
00078 }
00079
00080 if ((*locs)->flags&CPL_LOC_NATED)
00081 setbflag( 0, cpl_fct.ulb.nat_flag );
00082
00083 foo = (*locs)->next;
00084 free_location( *locs );
00085 *locs = foo;
00086 }
00087
00088
00089 while(*locs) {
00090 bflags = ((*locs)->flags&CPL_LOC_NATED) ? cpl_fct.ulb.nat_flag : 0 ;
00091 LM_DBG("appending branch <%.*s>, flags %d\n",
00092 (*locs)->addr.uri.len, (*locs)->addr.uri.s, bflags);
00093 if(append_branch(msg, &(*locs)->addr.uri, &(*locs)->addr.received,0,
00094 Q_UNSPECIFIED, bflags, 0)==-1){
00095 LM_ERR("failed when appending branch <%s>\n",(*locs)->addr.uri.s);
00096 goto error;
00097 }
00098
00099 foo = (*locs)->next;
00100 free_location( *locs );
00101 *locs = foo;
00102 }
00103
00104
00105 if (cpl_env.proxy_route) {
00106
00107 run_top_route( rlist[cpl_env.proxy_route], msg);
00108 }
00109
00110
00111 if (cpl_fct.tmb.t_relay(msg, 0, 0, 0, 0, 0, 0)==-1) {
00112 LM_ERR("t_relay failed !\n");
00113 goto error;
00114 }
00115
00116 return 0;
00117 error:
00118 return -1;
00119 }
00120
00121