Ignore:
Timestamp:
Jan 1, 2014, 12:47:38 AM (7 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.21.1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mindi-busybox/libbb/xconnect.c

    r2725 r3232  
    135135}
    136136
    137 void FAST_FUNC set_nport(len_and_sockaddr *lsa, unsigned port)
    138 {
    139 #if ENABLE_FEATURE_IPV6
    140     if (lsa->u.sa.sa_family == AF_INET6) {
    141         lsa->u.sin6.sin6_port = port;
     137void FAST_FUNC set_nport(struct sockaddr *sa, unsigned port)
     138{
     139#if ENABLE_FEATURE_IPV6
     140    if (sa->sa_family == AF_INET6) {
     141        struct sockaddr_in6 *sin6 = (void*) sa;
     142        sin6->sin6_port = port;
    142143        return;
    143144    }
    144145#endif
    145     if (lsa->u.sa.sa_family == AF_INET) {
    146         lsa->u.sin.sin_port = port;
     146    if (sa->sa_family == AF_INET) {
     147        struct sockaddr_in *sin = (void*) sa;
     148        sin->sin_port = port;
    147149        return;
    148150    }
     
    256258    memset(&hint, 0 , sizeof(hint));
    257259    hint.ai_family = af;
    258     /* Needed. Or else we will get each address thrice (or more)
     260    /* Need SOCK_STREAM, or else we get each address thrice (or more)
    259261     * for each possible socket type (tcp,udp,raw...): */
    260262    hint.ai_socktype = SOCK_STREAM;
     
    284286
    285287 set_port:
    286     set_nport(r, htons(port));
     288    set_nport(&r->u.sa, htons(port));
    287289 ret:
    288     freeaddrinfo(result);
     290    if (result)
     291        freeaddrinfo(result);
    289292    return r;
    290293}
     
    320323}
    321324
    322 #undef xsocket_type
    323 int FAST_FUNC xsocket_type(len_and_sockaddr **lsap, IF_FEATURE_IPV6(int family,) int sock_type)
    324 {
    325     IF_NOT_FEATURE_IPV6(enum { family = AF_INET };)
     325int FAST_FUNC xsocket_type(len_and_sockaddr **lsap, int family, int sock_type)
     326{
    326327    len_and_sockaddr *lsa;
    327328    int fd;
    328329    int len;
    329330
    330 #if ENABLE_FEATURE_IPV6
    331331    if (family == AF_UNSPEC) {
     332#if ENABLE_FEATURE_IPV6
    332333        fd = socket(AF_INET6, sock_type, 0);
    333334        if (fd >= 0) {
     
    335336            goto done;
    336337        }
     338#endif
    337339        family = AF_INET;
    338340    }
    339 #endif
     341
    340342    fd = xsocket(family, sock_type, 0);
     343
    341344    len = sizeof(struct sockaddr_in);
     345    if (family == AF_UNIX)
     346        len = sizeof(struct sockaddr_un);
    342347#if ENABLE_FEATURE_IPV6
    343348    if (family == AF_INET6) {
     
    355360int FAST_FUNC xsocket_stream(len_and_sockaddr **lsap)
    356361{
    357     return xsocket_type(lsap, IF_FEATURE_IPV6(AF_UNSPEC,) SOCK_STREAM);
     362    return xsocket_type(lsap, AF_UNSPEC, SOCK_STREAM);
    358363}
    359364
     
    368373        fd = xsocket(lsa->u.sa.sa_family, sock_type, 0);
    369374    } else {
    370         fd = xsocket_type(&lsa, IF_FEATURE_IPV6(AF_UNSPEC,) sock_type);
    371         set_nport(lsa, htons(port));
     375        fd = xsocket_type(&lsa, AF_UNSPEC, sock_type);
     376        set_nport(&lsa->u.sa, htons(port));
    372377    }
    373378    setsockopt_reuseaddr(fd);
Note: See TracChangeset for help on using the changeset viewer.