Changeset 2e3ba71 in rtems


Ignore:
Timestamp:
Jul 1, 2016, 1:16:10 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
0057e38f
Parents:
df2177ab
Message:

net: Fix byte order issue for getnameinfo()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/libc/getnameinfo.c

    rdf2177ab r2e3ba71  
    3939        /* FIXME: This return just the address value. Try resolving instead. */
    4040        if (node != NULL && nodelen > 0) {
    41                 const void *addr = &sa_in->sin_addr;
    42 
    43                 if(inet_ntop(af, addr, node, nodelen) == NULL) {
     41                if (inet_ntop(af, &sa_in->sin_addr, node, nodelen) == NULL) {
    4442                        return EAI_FAIL;
    4543                }
     
    4745
    4846        if (service != NULL && servicelen > 0) {
    49                 in_port_t port = sa_in->sin_port;
     47                in_port_t port = ntohs(sa_in->sin_port);
    5048                int rv;
    5149
  • testsuites/libtests/networking01/init.c

    rdf2177ab r2e3ba71  
    3232static void fill_sa(struct sockaddr *sa, sa_family_t family)
    3333{
    34   memset(sa, 0, sizeof(struct sockaddr));
    35   sa->sa_len = sizeof(struct sockaddr);
     34  memset(sa, 0, sizeof(*sa));
     35  sa->sa_len = sizeof(*sa);
    3636  sa->sa_family = family;
    3737}
     
    4141{
    4242  fill_sa((struct sockaddr *)sa_in, AF_INET);
    43   sa_in->sin_port = port;
    44   sa_in->sin_addr.s_addr = addr;
     43  sa_in->sin_port = htons(port);
     44  sa_in->sin_addr.s_addr = htonl(addr);
    4545}
    4646
     
    106106
    107107
    108   printk("Try AF_INET6\n");
     108  puts("Try AF_INET6");
    109109  fill_sa(&sa, AF_INET6);
    110110  test_getnameinfo(&sa, 0, true, true, EAI_FAMILY, NULL, NULL);
    111111
    112   printk("force node name\n");
     112  puts("force node name");
    113113  fill_sa_in(&sa_in, ip1_num, port1_num);
    114114  test_getnameinfo(sa_in_p, NI_NAMEREQD, true, true, EAI_NONAME, NULL, NULL);
    115115
    116   printk("force service name\n");
     116  puts("force service name");
    117117  fill_sa_in(&sa_in, ip1_num, port1_num);
    118118  test_getnameinfo(sa_in_p, NI_NAMEREQD, true, true, EAI_NONAME, NULL, NULL);
    119119
    120   printk("get node only\n");
     120  puts("get node only");
    121121  fill_sa_in(&sa_in, ip1_num, port1_num);
    122122  test_getnameinfo(sa_in_p, 0, true, false, 0, ip1_string, NULL);
    123123
    124   printk("get service only\n");
     124  puts("get service only");
    125125  fill_sa_in(&sa_in, ip1_num, port1_num);
    126126  test_getnameinfo(sa_in_p, 0, false, true, 0, NULL, port1_string);
    127127
    128   printk("get node and service\n");
     128  puts("get node and service");
    129129  fill_sa_in(&sa_in, ip1_num, port1_num);
    130130  test_getnameinfo(sa_in_p, 0, true, true, 0, ip1_string, port1_string);
    131131
    132   printk("get node and service with maximum number of characters for IP\n");
     132  puts("get node and service with maximum number of characters for IP");
    133133  fill_sa_in(&sa_in, ip2_num, port2_num);
    134134  test_getnameinfo(sa_in_p, 0, true, true, 0, ip2_string, port2_string);
Note: See TracChangeset for help on using the changeset viewer.