Changeset 26de91a in mainline for uspace/srv/net/dnsrsrv/transport.c


Ignore:
Timestamp:
2013-10-04T17:19:20Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9749e47
Parents:
e2839d7
Message:

IPv4 and v6 should not need separate handling by a simple client that is just connecting to a host/address. Add IPv6/DNS support in applications where missing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dnsrsrv/transport.c

    re2839d7 r26de91a  
    182182{
    183183        trans_req_t *treq = NULL;
     184        struct sockaddr *saddr = NULL;
     185        socklen_t saddrlen;
    184186       
    185187        void *req_data;
     
    189191                goto error;
    190192       
    191         struct sockaddr_in addr;
    192         struct sockaddr_in6 addr6;
    193         uint16_t af =
    194             inet_addr_sockaddr_in(&dns_server_addr, &addr, &addr6);
    195        
    196         struct sockaddr *address;
    197         socklen_t addrlen;
    198        
    199         switch (af) {
    200         case AF_INET:
    201                 addr.sin_port = htons(DNS_SERVER_PORT);
    202                 address = (struct sockaddr *) &addr;
    203                 addrlen = sizeof(addr);
    204                 break;
    205         case AF_INET6:
    206                 addr6.sin6_port = htons(DNS_SERVER_PORT);
    207                 address = (struct sockaddr *) &addr6;
    208                 addrlen = sizeof(addr6);
    209                 break;
    210         default:
    211                 rc = EAFNOSUPPORT;
     193        rc = inet_addr_sockaddr(&dns_server_addr, DNS_SERVER_PORT,
     194            &saddr, &saddrlen);
     195        if (rc != EOK) {
     196                assert(rc == ENOMEM);
    212197                goto error;
    213198        }
     
    217202        while (ntry < REQ_RETRY_MAX) {
    218203                rc = sendto(transport_fd, req_data, req_size, 0,
    219                     (struct sockaddr *) address, addrlen);
     204                    saddr, saddrlen);
    220205                if (rc != EOK)
    221206                        goto error;
     
    256241        treq_destroy(treq);
    257242        free(req_data);
     243        free(saddr);
    258244        return EOK;
    259245       
     
    263249       
    264250        free(req_data);
     251        free(saddr);
    265252        return rc;
    266253}
Note: See TracChangeset for help on using the changeset viewer.