Skip to content

Commit

Permalink
sip: sip_conncfg_set pass by reference (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored Oct 20, 2022
1 parent 4f13228 commit de4e68f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/re_sip.h
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ int sip_keepalive_start(struct sip_keepalive **kap, struct sip *sip,

/* sip_conncfg */
int sip_conncfg_set(struct sip *sip, const struct sa *paddr,
const struct sip_conncfg conncfg);
const struct sip_conncfg *conncfg);


/* sip_uas_auth */
Expand Down
7 changes: 4 additions & 3 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1873,7 +1873,7 @@ void sip_transp_rmladdr(struct sip *sip, const struct sa *laddr)
* @return 0 if success, otherwise errorcode
*/
int sip_conncfg_set(struct sip *sip, const struct sa *paddr,
const struct sip_conncfg conncfg)
const struct sip_conncfg *conncfg)
{
struct sip_conncfg *cfg;

Expand All @@ -1882,7 +1882,7 @@ int sip_conncfg_set(struct sip *sip, const struct sa *paddr,

cfg = sip_conncfg_find(sip, paddr);
if (cfg) {
cfg->srcport = conncfg.srcport;
cfg->srcport = conncfg->srcport;
return 0;
}
else {
Expand All @@ -1892,9 +1892,10 @@ int sip_conncfg_set(struct sip *sip, const struct sa *paddr,
if (!cfg)
return ENOMEM;

memcpy(cfg, &conncfg, sizeof(*cfg));
memcpy(cfg, conncfg, sizeof(*cfg));
memset(&cfg->he, 0, sizeof(cfg->he));
sa_cpy(&cfg->paddr, paddr);
hash_append(sip->ht_conncfg, sa_hash(paddr, SA_ALL), &cfg->he, cfg);

return 0;
}
2 changes: 1 addition & 1 deletion src/sipreg/reg.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ static int send_handler(enum sip_transp tp, struct sa *src,
struct sip_conncfg cfg;
memset(&cfg, 0, sizeof(cfg));
cfg.srcport = reg->srcport;
err = sip_conncfg_set(reg->sip, dst, cfg);
err = sip_conncfg_set(reg->sip, dst, &cfg);
}

return err;
Expand Down

0 comments on commit de4e68f

Please sign in to comment.