about pj_sockaddr_init

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 30, 2008 at 3:00 AM, McAuther <mcauther312 at yahoo.com.tw> wrote:

>
>  Hi , I have found some issues about pj_sockaddr_init() using pjsip 0.9.0
> !!
>
>  <1> In
>
> PJ_DEF(pj_status_t) pj_sockaddr_init(int af,
>          pj_sockaddr *addr,
>          const pj_str_t *cp,
>          pj_uint16_t port)
> {
>     pj_status_t status;
>     if (af == PJ_AF_INET) {
>
>
>  addr->addr.sa_family = PJ_AF_INET;
>  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I think here could add this
> line , If comparing with ipv6 version
>

The sa_family will be initialized by pj_sockaddr_in_init() below, so no need
to set it there.


>
>  return pj_sockaddr_in_init(&addr->ipv4, cp, port);
>     }
>     /* IPv6 specific */
>     PJ_ASSERT_RETURN(af==PJ_AF_INET6, PJ_EAFNOTSUP);
>     pj_bzero(addr, sizeof(pj_sockaddr_in6));
>     addr->addr.sa_family = PJ_AF_INET6;
>
>     status = pj_sockaddr_set_str_addr(af, addr, cp);
>     if (status != PJ_SUCCESS)
>  return status;
>     addr->ipv6.sin6_port = pj_htons(port);
>     return PJ_SUCCESS;
> }
>
>
> <2> in sock_common.c --> static pj_status_t create_sip_udp_sock()
>
> (pj_sockaddr_has_addr(&bind_addr)) {
>
>
>      pj_sockaddr_init(af, p_pub_addr , NULL, (pj_uint16_t)0);
>      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I
> think here should add this line
>                                                   because in next line
> "pj_sockaddr_copy_addr()" will check if "sa_family" type is correct !!
>
>
In later pjsip, the pj_sockaddr_copy_addr() below has been modified so that
it doesn't inspect the sa_family in the destination address. So that line is
also not necessary.

Thanks for the comments though.

Cheers
 Benny



>      pj_sockaddr_copy_addr(p_pub_addr, &bind_addr);
>  } else {
>      status = pj_gethostip(af, p_pub_addr);
>      if (status != PJ_SUCCESS) {
>   pjsua_perror(THIS_FILE, "Unable to get local host IP", status);
>   pj_sock_close(sock);
>   return status;
>      }
>  }
>
>
>
> These suggestions is just derived from my porting work !! Thanks !!
>
>
>
> _______________________________________________
> Visit our blog: http://blog.pjsip.org
>
> pjsip mailing list
> pjsip at lists.pjsip.org
> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20080930/0e0a8341/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux