{ REFER_NOAUTH, "Failed - auth failure" }
} ;
+/*! \brief Structure to handle SIP transfers. Dynamically allocated when needed */
+/* OEJ: Should be moved to string fields */
+struct sip_refer {
+ char refer_to[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO extension */
+ char refer_to_domain[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO domain */
+ char refer_to_urioption[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO uri options */
+ char refer_to_context[AST_MAX_EXTENSION]; /*!< Place to store REFER-TO context */
+ char referred_by[AST_MAX_EXTENSION]; /*!< Place to store REFERRED-BY extension */
+ char referred_by_name[AST_MAX_EXTENSION]; /*!< Place to store REFERRED-BY extension */
+ char refer_contact[AST_MAX_EXTENSION]; /*!< Place to store Contact info from a REFER extension */
+ char replaces_callid[BUFSIZ]; /*!< Replace info */
+ char replaces_callid_totag[BUFSIZ/2]; /*!< Replace info */
+ char replaces_callid_fromtag[BUFSIZ/2]; /*!< Replace info */
+ struct sip_pvt *refer_call; /*!< Call we are referring */
+ int attendedtransfer; /*!< Attended or blind transfer? */
+ int localtransfer; /*!< Transfer to local domain? */
+ enum referstatus status; /*!< REFER status */
+};
/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe */
static struct sip_pvt {
int laststate; /*!< SUBSCRIBE: Last known extension state */
int dialogver; /*!< SUBSCRIBE: Version for subscription dialog-info */
+ struct sip_refer *refer; /*!< REFER: SIP transfer data structure */
struct ast_dsp *vad; /*!< Voice Activation Detection dsp */
struct sip_peer *relatedpeer; /*!< If this dialog is related to a peer, which one
}
-
-
/*! \brief Initiate SIP call from PBX
* used from the dial() application */
static int sip_call(struct ast_channel *ast, char *dest, int timeout)
struct sip_pvt *p;
struct varshead *headp;
struct ast_var_t *current;
-
+ const char *referer = NULL; /* SIP refererer */
+
p = ast->tech_pvt;
if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
ast_log(LOG_WARNING, "sip_call called on %s, neither down nor reserved\n", ast->name);
} else if (!p->options->addsipheaders && !strncasecmp(ast_var_name(current), "SIPADDHEADER", strlen("SIPADDHEADER"))) {
/* Check whether there is a variable with a name starting with SIPADDHEADER */
p->options->addsipheaders = 1;
+ } else if (!strcasecmp(ast_var_name(current),"SIPTRANSFER")) {
+ /* This is a transfered call */
+ p->options->transfer = 1;
+ } else if (!strcasecmp(ast_var_name(current),"SIPTRANSFER_REFERER")) {
+ /* This is the referer */
+ referer = ast_var_value(current);
+ } else if (!strcasecmp(ast_var_name(current),"SIPTRANSFER_REPLACES")) {
+ /* We're replacing a call. */
+ p->options->replaces = ast_var_value(current);
}
}
res = 0;
ast_set_flag(&p->flags[0], SIP_OUTGOING);
+
+ if (p->options->transfer) {
+ char buf[BUFSIZ/2];
+
+ if (referer) {
+ if (sipdebug && option_debug > 2)
+ ast_log(LOG_DEBUG, "Call for %s transfered by %s\n", p->username, referer);
+ snprintf(buf, sizeof(buf)-1, "-> %s (via %s)", p->cid_name, referer);
+ } else {
+ snprintf(buf, sizeof(buf)-1, "-> %s", p->cid_name);
+ }
+ ast_string_field_set(p, cid_name, buf);
+ }
if (option_debug)
ast_log(LOG_DEBUG, "Outgoing Call for %s\n", p->username);
+
res = update_call_counter(p, INC_CALL_LIMIT);
if ( res != -1 ) {
p->callingpres = ast->cid.cid_pres;
return send_request(p, &req, 1, p->ocseq);
}
+/*! \brief Allocate SIP refer structure */
+int sip_refer_allocate(struct sip_pvt *p) {
+ p->refer = ast_calloc(1, sizeof(struct sip_refer));
+ return p->refer ? 1 : 0;
+}
+
/*! \brief Transmit SIP REFER message */
static int transmit_refer(struct sip_pvt *p, const char *dest)
{