register a callback function 'f' for 'types' mask of events; * will be called back whenever one of the events occurs in transaction module * (global or per transaction, depending of event type) */
| 124 | * (global or per transaction, depending of event type) |
| 125 | */ |
| 126 | int register_tmcb( struct sip_msg* p_msg, struct cell *t, int types, |
| 127 | transaction_cb f, void *param, release_tmcb_param release_func ) |
| 128 | { |
| 129 | struct tmcb_head_list *cb_list; |
| 130 | |
| 131 | /* are the callback types valid?... */ |
| 132 | if ( types<0 || types>TMCB_MAX ) { |
| 133 | LM_CRIT("invalid callback types: mask=%d\n", |
| 134 | types); |
| 135 | return E_BUG; |
| 136 | } |
| 137 | /* we don't register null functions */ |
| 138 | if (f==0) { |
| 139 | LM_CRIT("null callback function\n"); |
| 140 | return E_BUG; |
| 141 | } |
| 142 | |
| 143 | if (types&(TMCB_REQUEST_IN|TMCB_LOCAL_TRANS_NEW)) { |
| 144 | if (types&(~(TMCB_REQUEST_IN|TMCB_LOCAL_TRANS_NEW))) { |
| 145 | LM_CRIT("callback type TMCB_REQUEST_IN and/or TMCB_LOCAL_TRANS_NEW " |
| 146 | "can't be register along with other types\n"); |
| 147 | return E_BUG; |
| 148 | } |
| 149 | if (new_tran_tmcb_hl==0) { |
| 150 | LM_ERR("callback type TMCB_REQUEST_IN and/or TMCB_LOCAL_TRANS_NEW " |
| 151 | "registration attempt before TM module initialization\n"); |
| 152 | return E_CFG; |
| 153 | } |
| 154 | cb_list = new_tran_tmcb_hl; |
| 155 | } else { |
| 156 | if (!t) { |
| 157 | if (!p_msg) { |
| 158 | LM_CRIT("no sip_msg, nor transaction given\n"); |
| 159 | return E_BUG; |
| 160 | } |
| 161 | /* look for the transaction */ |
| 162 | t = get_t(); |
| 163 | if ( t!=NULL && t!=T_UNDEFINED ){ |
| 164 | cb_list = &(t->tmcb_hl); |
| 165 | } else { |
| 166 | /* no transaction found -> link it to waitting list */ |
| 167 | if (p_msg->id!=tmcb_pending_id) { |
| 168 | empty_tmcb_list(&tmcb_pending_hl); |
| 169 | tmcb_pending_id = p_msg->id; |
| 170 | } |
| 171 | cb_list = &(tmcb_pending_hl); |
| 172 | } |
| 173 | } else { |
| 174 | cb_list = &(t->tmcb_hl); |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | return insert_tmcb( cb_list, types, f, param, release_func ); |
| 179 | } |
| 180 | |
| 181 | |
| 182 | static void *tmcb_extra1 = NULL; |
nothing calls this directly
no test coverage detected