diff options
author | Benny Prijono <bennylp@teluu.com> | 2013-02-19 16:27:37 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2013-02-19 16:27:37 +0000 |
commit | 9fc261c45952ec8bedceec689ea8b5a734c86b7d (patch) | |
tree | 2d8cdb4bfa848c8e1a4f9dfa8bc4823c917fb06c /pjlib/src | |
parent | 5899bdad96a27be0b0cbf5db1b6351a3513684bf (diff) |
More #1613: fixed bugs in the 'fixes' above:
- the socket was closed when ioctl() is called
- the 'iff' structure was not initialized
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@4355 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/src')
-rw-r--r-- | pjlib/src/pj/ip_helper_generic.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/pjlib/src/pj/ip_helper_generic.c b/pjlib/src/pj/ip_helper_generic.c index 0adefebb..b85e336d 100644 --- a/pjlib/src/pj/ip_helper_generic.c +++ b/pjlib/src/pj/ip_helper_generic.c @@ -165,9 +165,6 @@ static pj_status_t if_enum_by_af(int af, return PJ_RETURN_OS_ERROR(oserr); } - /* Done with socket */ - pj_sock_close(sock); - /* Interface interfaces */ ifr = (struct ifreq*) ifc.ifc_req; count = ifc.ifc_len / sizeof(struct ifreq); @@ -177,7 +174,7 @@ static pj_status_t if_enum_by_af(int af, *p_cnt = 0; for (i=0; i<count; ++i) { struct ifreq *itf = &ifr[i]; - struct ifreq iff; + struct ifreq iff = *itf; struct sockaddr *ad = &itf->ifr_addr; TRACE_((THIS_FILE, " checking interface %s", itf->ifr_name)); @@ -227,10 +224,14 @@ static pj_status_t if_enum_by_af(int af, (*p_cnt)++; } + /* Done with socket */ + pj_sock_close(sock); + TRACE_((THIS_FILE, "done, found %d address(es)", *p_cnt)); return (*p_cnt != 0) ? PJ_SUCCESS : PJ_ENOTFOUND; } + #elif defined(PJ_HAS_NET_IF_H) && PJ_HAS_NET_IF_H != 0 /* Note: this does not work with IPv6 */ static pj_status_t if_enum_by_af(int af, unsigned *p_cnt, pj_sockaddr ifs[]) |