ast_string_field_set(r, callid, p->callid);
if (r->portno)
p->sa.sin_port = htons(r->portno);
- ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Registration is outgoing call */
+ else /* Set registry port to the port set from the peer definition/srv or default */
+ r->portno = p->sa.sin_port;
+ ast_set_flag(p, SIP_OUTGOING); /* Registration is outgoing call */
r->call=p; /* Save pointer to SIP packet */
p->registry = ASTOBJ_REF(r); /* Add pointer to registry in packet */
if (!ast_strlen_zero(r->secret)) /* Secret (password) */