Skip to content

Commit

Permalink
Added sippreg_unregister API function (#400)
Browse files Browse the repository at this point in the history
* Added sippreg_unregister API function

* Fixed typo in comment

* Return void from sipreg_unregister

* Return void from sipreg_unregister

* Minor reorganization of `if (!reg->expires)` statement
  • Loading branch information
juha-h authored Jun 17, 2022
1 parent ab2870a commit 239b378
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
1 change: 1 addition & 0 deletions include/re_sipreg.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ int sipreg_register(struct sipreg **regp, struct sip *sip, const char *reg_uri,
int regid, sip_auth_h *authh, void *aarg, bool aref,
sip_resp_h *resph, void *arg,
const char *params, const char *fmt, ...);
void sipreg_unregister(struct sipreg *reg);
int sipreg_alloc(struct sipreg **regp, struct sip *sip, const char *reg_uri,
const char *to_uri, const char *from_name,
const char *from_uri, uint32_t expires,
Expand Down
31 changes: 25 additions & 6 deletions src/sipreg/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,17 @@ static void response_handler(int err, const struct sip_msg *msg, void *arg)
if (msg && msg->scode >= 400 && msg->scode < 500)
reg->fbregint = 0;

if (!reg->terminated && reg->fbregint) {
tmr_start(&reg->tmr, reg->fbregint * 1000, tmr_handler,
reg);
reg->resph(err, msg, reg->arg);
}
else if (reg->terminated) {
if (reg->terminated) {
mem_deref(reg);
return;
}

if (reg->fbregint)
tmr_start(&reg->tmr, reg->fbregint * 1000,
tmr_handler, reg);

reg->resph(err, msg, reg->arg);

}
else if (reg->terminated) {
if (!reg->registered || request(reg, true))
Expand Down Expand Up @@ -450,6 +453,22 @@ int sipreg_register(struct sipreg **regp, struct sip *sip, const char *reg_uri,
}


/**
* Unregisters SIP Registration client
*
* @param reg SIP Registration client
*/
void sipreg_unregister(struct sipreg *reg)
{
if (!reg)
return;

reg->expires = 0;

(void)sipreg_send(reg);
}


/**
* Allocate a SIP Registration client
*
Expand Down

0 comments on commit 239b378

Please sign in to comment.