MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / t_check_status

Function t_check_status

modules/tm/tm.c:1072–1122  ·  view source on GitHub ↗

wrapper functions ***************************/

Source from the content-addressed store, hash-verified

1070
1071/**************************** wrapper functions ***************************/
1072static int t_check_status(struct sip_msg* msg, regex_t *regexp)
1073{
1074 regmatch_t pmatch;
1075 struct cell *t;
1076 char *status;
1077 char backup;
1078 int branch;
1079 int n;
1080
1081 /* first get the transaction */
1082 t = get_t();
1083 if ( t==0 || t==T_UNDEFINED ) {
1084 LM_ERR("cannot check status for a reply which"
1085 " has no transaction-state established\n");
1086 return -1;
1087 }
1088 backup = 0;
1089
1090 switch (route_type) {
1091 case REQUEST_ROUTE:
1092 /* use the status of the last sent reply */
1093 status = int2str( t->uas.status, 0);
1094 break;
1095 case ONREPLY_ROUTE:
1096 /* use the status of the current reply */
1097 status = msg->first_line.u.reply.status.s;
1098 backup = status[msg->first_line.u.reply.status.len];
1099 status[msg->first_line.u.reply.status.len] = 0;
1100 break;
1101 case FAILURE_ROUTE:
1102 /* use the status of the winning reply */
1103 if ( (branch=t_get_picked_branch())<0 ) {
1104 LM_CRIT("no picked branch (%d) for a final response"
1105 " in MODE_ONFAILURE\n", branch);
1106 return -1;
1107 }
1108 status = int2str( TM_BRANCH(t,branch).last_received , 0);
1109 break;
1110 default:
1111 LM_ERR("unsupported route_type %d\n", route_type);
1112 return -1;
1113 }
1114
1115 LM_DBG("checked status is <%s>\n",status);
1116 /* do the checking */
1117 n = regexec(regexp, status, 1, &pmatch, 0);
1118
1119 if (backup) status[msg->first_line.u.reply.status.len] = backup;
1120 if (n!=0) return -1;
1121 return 1;
1122}
1123
1124
1125static int t_check_trans(struct sip_msg* msg)

Callers

nothing calls this directly

Calls 3

get_tFunction · 0.85
int2strFunction · 0.85
t_get_picked_branchFunction · 0.85

Tested by

no test coverage detected