osp/tm.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
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "../tm/tm_load.h"
00036 #include "tm.h"
00037 #include "destination.h"
00038
00039 struct tm_binds osp_tmb;
00040
00041 static void ospOnReq(struct cell* t, int type, struct tmcb_params* ps);
00042 static void ospTmcbFunc(struct cell* t, int type, struct tmcb_params* ps);
00043
00044
00045
00046
00047
00048 int ospInitTm(void)
00049 {
00050 if (load_tm_api(&osp_tmb) != 0) {
00051 LM_ERR("failed to load TM API\n");
00052 LM_ERR("TM is required for reporting call setup usage\n");
00053 return -1;
00054 }
00055
00056
00057 if (osp_tmb.register_tmcb(0, 0, TMCB_REQUEST_IN, ospOnReq, 0, 0) <= 0) {
00058 LM_ERR("failed to register TMCB_REQUEST_IN callback\n");
00059 LM_ERR("TM callbacks are required for reporting call set up usage\n");
00060 return -1;
00061 }
00062
00063 return 0;
00064 }
00065
00066
00067
00068
00069
00070
00071
00072 static void ospOnReq(
00073 struct cell* t,
00074 int type,
00075 struct tmcb_params* ps)
00076 {
00077 int tmcb_types;
00078
00079
00080 tmcb_types =
00081
00082
00083 TMCB_ON_FAILURE |
00084
00085
00086 TMCB_RESPONSE_OUT |
00087
00088 TMCB_E2EACK_IN |
00089
00090 TMCB_ON_FAILURE_RO |
00091
00092
00093 0;
00094
00095 if (osp_tmb.register_tmcb(0, t, tmcb_types, ospTmcbFunc, 0, 0) <= 0) {
00096 LM_ERR("failed to register TM callbacks\n");
00097 LM_ERR("TM callbacks are required for reporting call setup usage\n");
00098 return;
00099 }
00100 }
00101
00102
00103
00104
00105
00106
00107
00108 static void ospTmcbFunc(
00109 struct cell* t,
00110 int type,
00111 struct tmcb_params* ps)
00112 {
00113 if (type & TMCB_RESPONSE_OUT) {
00114 LM_DBG("RESPONSE_OUT\n");
00115 } else if (type & TMCB_E2EACK_IN) {
00116 LM_DBG("E2EACK_IN\n");
00117 } else if (type & TMCB_ON_FAILURE_RO) {
00118 LM_DBG("FAILURE_RO\n");
00119 } else if (type & TMCB_RESPONSE_IN) {
00120 LM_DBG("RESPONSE_IN\n");
00121 } else if (type & TMCB_REQUEST_FWDED) {
00122 LM_DBG("REQUEST_FWDED\n");
00123 } else if (type & TMCB_RESPONSE_FWDED) {
00124 LM_DBG("RESPONSE_FWDED\n");
00125 } else if (type & TMCB_ON_FAILURE) {
00126 LM_DBG("FAILURE\n");
00127 } else if (type & TMCB_LOCAL_COMPLETED) {
00128 LM_DBG("COMPLETED\n");
00129 } else {
00130 LM_DBG("something else '%d'\n", type);
00131 }
00132
00133 if (t) {
00134 ospRecordEvent(t->uac[t->first_branch].last_received, t->uas.status);
00135 } else {
00136 LM_DBG("cell is empty\n");
00137 }
00138 }