Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIP redirect callbackfunction #111

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/re_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ int sip_dialog_fork(struct sip_dialog **dlgp, struct sip_dialog *odlg,
int sip_dialog_update(struct sip_dialog *dlg, const struct sip_msg *msg);
bool sip_dialog_rseq_valid(struct sip_dialog *dlg, const struct sip_msg *msg);
const char *sip_dialog_callid(const struct sip_dialog *dlg);
const char *sip_dialog_uri(const struct sip_dialog *dlg);
uint32_t sip_dialog_lseq(const struct sip_dialog *dlg);
bool sip_dialog_established(const struct sip_dialog *dlg);
bool sip_dialog_cmp(const struct sip_dialog *dlg, const struct sip_msg *msg);
Expand Down
5 changes: 5 additions & 0 deletions include/re_sipsess.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ typedef void (sipsess_refer_h)(struct sip *sip, const struct sip_msg *msg,
void *arg);
typedef void (sipsess_close_h)(int err, const struct sip_msg *msg, void *arg);

typedef void (sipsess_redirect_h)(const struct sip_msg *msg,
const char *uri, void *arg);

int sipsess_listen(struct sipsess_sock **sockp, struct sip *sip,
int htsize, sipsess_conn_h *connh, void *arg);
Expand All @@ -45,6 +47,9 @@ int sipsess_accept(struct sipsess **sessp, struct sipsess_sock *sock,
sipsess_refer_h *referh, sipsess_close_h *closeh,
void *arg, const char *fmt, ...);

int sipsess_set_redirect_handler(struct sipsess *sess,
sipsess_redirect_h *redirecth);

int sipsess_progress(struct sipsess *sess, uint16_t scode,
const char *reason, struct mbuf *desc,
const char *fmt, ...);
Expand Down
1 change: 0 additions & 1 deletion src/sip/sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ int sip_auth_encode(struct mbuf *mb, struct sip_auth *auth, const char *met,
/* dialog */
int sip_dialog_encode(struct mbuf *mb, struct sip_dialog *dlg, uint32_t cseq,
const char *met);
const char *sip_dialog_uri(const struct sip_dialog *dlg);
const struct uri *sip_dialog_route(const struct sip_dialog *dlg);
uint32_t sip_dialog_hash(const struct sip_dialog *dlg);

Expand Down
4 changes: 4 additions & 0 deletions src/sipsess/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ static void invite_resp_handler(int err, const struct sip_msg *msg, void *arg)
if (err)
goto out;

if (sess->redirecth)
sess->redirecth(msg, sip_dialog_uri(sess->dlg),
sess->arg);

err = invite(sess);
if (err)
goto out;
Expand Down
12 changes: 12 additions & 0 deletions src/sipsess/sess.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@ int sipsess_alloc(struct sipsess **sessp, struct sipsess_sock *sock,
}


int sipsess_set_redirect_handler(struct sipsess *sess,
sipsess_redirect_h *redirecth)
{
if (!sess || !redirecth)
return EINVAL;

sess->redirecth = redirecth;

return 0;
}


void sipsess_terminate(struct sipsess *sess, int err,
const struct sip_msg *msg)
{
Expand Down
1 change: 1 addition & 0 deletions src/sipsess/sipsess.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct sipsess {
sipsess_info_h *infoh;
sipsess_refer_h *referh;
sipsess_close_h *closeh;
sipsess_redirect_h *redirecth;
void *arg;
bool owner;
bool sent_offer;
Expand Down