int BrpcCtrlInterface::send(const AmSipRequest &amReq, char *serKey, unsigned int &serKeyLen) { int ret = -1; brpc_t *req, *rpl = NULL; brpc_int_t *code; brpc_str_t *ser_opaque; if (amReq.method == "CANCEL") { req = build_cancel(amReq); } else if (amReq.method == "ACK") { ERROR("ACK support not yet implemented.\n"); return -1; } else { req = build_request(amReq, as_id); } if (! req) return -1; rpl = rpcExecute(req); req = NULL; if (! rpl) goto end; if (! brpc_dsm(rpl, FMT_RPL, &code, &ser_opaque)) { ERROR("failed to disassebmle SER's response: %s [%d].\n", brpc_strerror(), brpc_errno); goto end; } if ((! code) || (! ser_opaque)) { ERROR("unexpected NULLs in SER's response (code@%p, opaque@%p).\n", code, ser_opaque); goto end; } if (300 <= *code) { ERROR("RPC request failed with code: %d, status: '%.*s'.\n", *code, /*misleading var. name!*/BRPC_STR_FMT(ser_opaque)); goto end; } DBG("SER's opaque/reason: `%.*s'.\n", BRPC_STR_FMT(ser_opaque)); //len must be fed, as the opaque could contain 0s memcpy(serKey, ser_opaque->val, ser_opaque->len); serKeyLen = ser_opaque->len; ret = 0; end: if (req) brpc_finish(req); if (rpl) brpc_finish(rpl); return ret; }
void cancel_branch( struct cell *t, int branch ) { char *cancel; unsigned int len; struct retr_buf *crb, *irb; crb=&t->uac[branch].local_cancel; irb=&t->uac[branch].request; # ifdef EXTRA_DEBUG if (crb->buffer.s!=0 && crb->buffer.s!=BUSY_BUFFER) { LM_CRIT("attempt to rewrite cancel buffer failed\n"); abort(); } # endif cancel=build_cancel(t, branch, &len); if (!cancel) { LM_ERR("attempt to build a CANCEL failed\n"); return; } /* install cancel now */ crb->buffer.s=cancel; crb->buffer.len=len; crb->dst=irb->dst; crb->branch=branch; /* label it as cancel so that FR timer can better now how * to deal with it */ crb->activ_type=TYPE_LOCAL_CANCEL; if ( has_tran_tmcbs( t, TMCB_REQUEST_BUILT) ) { set_extra_tmcb_params( &crb->buffer, &crb->dst); run_trans_callbacks( TMCB_REQUEST_BUILT, t, t->uas.request,0, -t->uas.request->REQ_METHOD); } LM_DBG("sending cancel...\n"); SEND_BUFFER( crb ); /*sets and starts the FINAL RESPONSE timer */ start_retr( crb ); }