sipsess: added sipsess_set_close_headers()
This commit is contained in:
parent
b9fcf9d0d6
commit
10e7c015b1
5 changed files with 40 additions and 2 deletions
|
@ -55,5 +55,6 @@ int sipsess_reject(struct sipsess *sess, uint16_t scode, const char *reason,
|
||||||
int sipsess_modify(struct sipsess *sess, struct mbuf *desc);
|
int sipsess_modify(struct sipsess *sess, struct mbuf *desc);
|
||||||
int sipsess_info(struct sipsess *sess, const char *ctype, struct mbuf *body,
|
int sipsess_info(struct sipsess *sess, const char *ctype, struct mbuf *body,
|
||||||
sip_resp_h *resph, void *arg);
|
sip_resp_h *resph, void *arg);
|
||||||
|
int sipsess_set_close_headers(struct sipsess *sess, const char *hdrs, ...);
|
||||||
void sipsess_close_all(struct sipsess_sock *sock);
|
void sipsess_close_all(struct sipsess_sock *sock);
|
||||||
struct sip_dialog *sipsess_dialog(const struct sipsess *sess);
|
struct sip_dialog *sipsess_dialog(const struct sipsess *sess);
|
||||||
|
|
|
@ -67,6 +67,8 @@ int sipsess_bye(struct sipsess *sess, bool reset_ls)
|
||||||
return sip_drequestf(&sess->req, sess->sip, true, "BYE",
|
return sip_drequestf(&sess->req, sess->sip, true, "BYE",
|
||||||
sess->dlg, 0, sess->auth,
|
sess->dlg, 0, sess->auth,
|
||||||
NULL, bye_resp_handler, sess,
|
NULL, bye_resp_handler, sess,
|
||||||
|
"%s"
|
||||||
"Content-Length: 0\r\n"
|
"Content-Length: 0\r\n"
|
||||||
"\r\n");
|
"\r\n",
|
||||||
|
sess->close_hdrs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,11 @@ static void bye_handler(struct sipsess_sock *sock, const struct sip_msg *msg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)sip_treply(NULL, sip, msg, 200, "OK");
|
(void)sip_treplyf(NULL, NULL, sip, msg, false, 200, "OK",
|
||||||
|
"%s"
|
||||||
|
"Content-Length: 0\r\n"
|
||||||
|
"\r\n",
|
||||||
|
sess->close_hdrs);
|
||||||
|
|
||||||
sess->peerterm = true;
|
sess->peerterm = true;
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@ static void destructor(void *arg)
|
||||||
mem_deref(sess->auth);
|
mem_deref(sess->auth);
|
||||||
mem_deref(sess->cuser);
|
mem_deref(sess->cuser);
|
||||||
mem_deref(sess->ctype);
|
mem_deref(sess->ctype);
|
||||||
|
mem_deref(sess->close_hdrs);
|
||||||
mem_deref(sess->hdrs);
|
mem_deref(sess->hdrs);
|
||||||
mem_deref(sess->desc);
|
mem_deref(sess->desc);
|
||||||
mem_deref(sess->sock);
|
mem_deref(sess->sock);
|
||||||
|
@ -232,3 +233,32 @@ struct sip_dialog *sipsess_dialog(const struct sipsess *sess)
|
||||||
{
|
{
|
||||||
return sess ? sess->dlg : NULL;
|
return sess ? sess->dlg : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set extra SIP headers for inclusion in Session "close" messages
|
||||||
|
* like BYE and 200 OK. Multiple headers can be included.
|
||||||
|
*
|
||||||
|
* @param sess SIP Session
|
||||||
|
* @param hdrs Formatted strings with extra SIP Headers
|
||||||
|
*
|
||||||
|
* @return 0 if success, otherwise errorcode
|
||||||
|
*/
|
||||||
|
int sipsess_set_close_headers(struct sipsess *sess, const char *hdrs, ...)
|
||||||
|
{
|
||||||
|
int err = 0;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
if (!sess)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
sess->close_hdrs = mem_deref(sess->close_hdrs);
|
||||||
|
|
||||||
|
if (hdrs) {
|
||||||
|
va_start(ap, hdrs);
|
||||||
|
err = re_vsdprintf(&sess->close_hdrs, hdrs, ap);
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct sipsess {
|
||||||
struct sip *sip;
|
struct sip *sip;
|
||||||
char *cuser;
|
char *cuser;
|
||||||
char *ctype;
|
char *ctype;
|
||||||
|
char *close_hdrs;
|
||||||
struct mbuf *hdrs;
|
struct mbuf *hdrs;
|
||||||
struct mbuf *desc;
|
struct mbuf *desc;
|
||||||
sipsess_offer_h *offerh;
|
sipsess_offer_h *offerh;
|
||||||
|
|
Loading…
Add table
Reference in a new issue