Changeset 1477

Show
Ignore:
Timestamp:
11/08/09 14:56:51 (10 months ago)
Author:
marek
Message:

[batctl] Correct printf format string conversation

Signed-off-by: Sven Eckelmann <sven.eckelmann@…>

Location:
trunk/batctl
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/batctl/ping.c

    r1476 r1477  
    149149        icmp_packet_out.seqno = 0; 
    150150 
    151         printf("PING %s (%s) %zi(%zi) bytes of data\n", dst_string, mac_string, 
     151        printf("PING %s (%s) %zu(%zu) bytes of data\n", dst_string, mac_string, 
    152152                sizeof(icmp_packet_out), sizeof(icmp_packet_out) + 28); 
    153153 
     
    197197 
    198198                if ((size_t)read_len < sizeof(icmp_packet_in)) { 
    199                         printf("Warning - dropping received packet as it is smaller than expected (%zd): %zd\n", 
     199                        printf("Warning - dropping received packet as it is smaller than expected (%zu): %zd\n", 
    200200                                sizeof(icmp_packet_in), read_len); 
    201201                        goto sleep; 
     
    205205                case ECHO_REPLY: 
    206206                        time_delta = end_timer(); 
    207                         printf("%zd bytes from %s icmp_seq=%u ttl=%d time=%.2f ms\n", 
     207                        printf("%zd bytes from %s icmp_seq=%hu ttl=%d time=%.2f ms\n", 
    208208                                        read_len, dst_string, ntohs(icmp_packet_in.seqno), 
    209209                                        icmp_packet_in.ttl, time_delta); 
     
    217217                        break; 
    218218                case DESTINATION_UNREACHABLE: 
    219                         printf("From %s: Destination Host Unreachable (icmp_seq %u)\n", dst_string, ntohs(icmp_packet_in.seqno)); 
     219                        printf("From %s: Destination Host Unreachable (icmp_seq %hu)\n", dst_string, ntohs(icmp_packet_in.seqno)); 
    220220                        break; 
    221221                case TTL_EXCEEDED: 
    222                         printf("From %s: Time to live exceeded (icmp_seq %u)\n", dst_string, ntohs(icmp_packet_in.seqno)); 
     222                        printf("From %s: Time to live exceeded (icmp_seq %hu)\n", dst_string, ntohs(icmp_packet_in.seqno)); 
    223223                        break; 
    224224                case PARAMETER_PROBLEM: 
     
    244244 
    245245        printf("--- %s ping statistics ---\n", dst_string); 
    246         printf("%d packets transmitted, %d received, %d%% packet loss\n", 
     246        printf("%u packets transmitted, %u received, %u%% packet loss\n", 
    247247                packets_out, packets_in, packets_loss); 
    248248        printf("rtt min/avg/max/mdev = %.3f/%.3f/%.3f/%.3f ms\n", 
  • trunk/batctl/tcpdump.c

    r1463 r1477  
    4646#define LEN_CHECK(buff_len, check_len, desc) \ 
    4747if ((size_t)(buff_len) < (check_len)) { \ 
    48         printf("Warning - dropping received %s packet as it is smaller than expected (%zd): %zd\n", \ 
     48        printf("Warning - dropping received %s packet as it is smaller than expected (%zu): %zu\n", \ 
    4949                desc, (check_len), (size_t)(buff_len)); \ 
    5050        return; \ 
     
    128128                switch (icmphdr->type) { 
    129129                case ICMP_ECHOREPLY: 
    130                         printf("%s: ICMP echo reply, id %u, seq %u, length %zd\n", 
     130                        printf("%s: ICMP echo reply, id %hu, seq %hu, length %zu\n", 
    131131                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    132132                                ntohs(icmphdr->un.echo.id), ntohs(icmphdr->un.echo.sequence), 
     
    143143 
    144144                                printf("%s: ICMP ", inet_ntoa(*(struct in_addr *)&iphdr->daddr)); 
    145                                 printf("%s udp port %u unreachable, length %zd\n", 
     145                                printf("%s udp port %hu unreachable, length %zu\n", 
    146146                                        inet_ntoa(*(struct in_addr *)&tmp_iphdr->daddr), 
    147147                                        ntohs(tmp_udphdr->dest), (size_t)buff_len - (iphdr->ihl * 4)); 
    148148                                break; 
    149149                        default: 
    150                                 printf("%s: ICMP unreachable %u, length %zd\n", 
     150                                printf("%s: ICMP unreachable %hhu, length %zu\n", 
    151151                                        inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    152152                                        icmphdr->code, (size_t)buff_len - (iphdr->ihl * 4)); 
     
    156156                        break; 
    157157                case ICMP_ECHO: 
    158                         printf("%s: ICMP echo request, id %u, seq %u, length %zd\n", 
     158                        printf("%s: ICMP echo request, id %hu, seq %hu, length %zu\n", 
    159159                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    160160                                ntohs(icmphdr->un.echo.id), ntohs(icmphdr->un.echo.sequence), 
     
    162162                        break; 
    163163                case ICMP_TIME_EXCEEDED: 
    164                         printf("%s: ICMP time exceeded in-transit, length %zd\n", 
     164                        printf("%s: ICMP time exceeded in-transit, length %zu\n", 
    165165                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    166166                                (size_t)buff_len - (iphdr->ihl * 4)); 
    167167                        break; 
    168168                default: 
    169                         printf("%s: ICMP type %u, length %zd\n", 
     169                        printf("%s: ICMP type %hhu, length %zu\n", 
    170170                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), icmphdr->type, 
    171171                                (size_t)buff_len - (iphdr->ihl * 4)); 
     
    179179                tcphdr = (struct tcphdr *)(packet_buff + (iphdr->ihl * 4)); 
    180180                printf("IP %s.%i > ", inet_ntoa(*(struct in_addr *)&iphdr->saddr), ntohs(tcphdr->source)); 
    181                 printf("%s.%i: TCP, flags [%c%c%c%c%c%c], length %zd\n", 
     181                printf("%s.%i: TCP, flags [%c%c%c%c%c%c], length %zu\n", 
    182182                        inet_ntoa(*(struct in_addr *)&iphdr->daddr), ntohs(tcphdr->dest), 
    183183                        (tcphdr->fin ? 'F' : '.'), (tcphdr->syn ? 'S' : '.'), 
     
    195195                case 67: 
    196196                        LEN_CHECK((size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct udphdr), (size_t) 44, "DHCP"); 
    197                         printf("%s.67: BOOTP/DHCP, Request from %s, length %zd\n", 
     197                        printf("%s.67: BOOTP/DHCP, Request from %s, length %zu\n", 
    198198                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    199199                                ether_ntoa_long((struct ether_addr *)(((char *)udphdr) + sizeof(struct udphdr) + 28)), 
     
    201201                        break; 
    202202                case 68: 
    203                         printf("%s.68: BOOTP/DHCP, Reply, length %zd\n", 
     203                        printf("%s.68: BOOTP/DHCP, Reply, length %zu\n", 
    204204                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), 
    205205                                (size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct udphdr)); 
    206206                        break; 
    207207                default: 
    208                         printf("%s.%i: UDP, length %zd\n", 
     208                        printf("%s.%i: UDP, length %zu\n", 
    209209                                inet_ntoa(*(struct in_addr *)&iphdr->daddr), ntohs(udphdr->dest), 
    210210                                (size_t)buff_len - (iphdr->ihl * 4) - sizeof(struct udphdr)); 
     
    237237               get_name_by_macaddr((struct ether_addr *)batman_packet->orig, read_opt)); 
    238238 
    239         printf("OGM via neigh %s, seqno %d, tq %3d, ttl %2d, v %d, flags [%c%c], length %zd\n", 
     239        printf("OGM via neigh %s, seqno %d, tq %3d, ttl %2d, v %d, flags [%c%c], length %zu\n", 
    240240                get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt), 
    241241                ntohs(batman_packet->seqno), batman_packet->tq, 
     
    265265        switch (icmp_packet->msg_type) { 
    266266        case ECHO_REPLY: 
    267                 printf("%s: ICMP echo reply, id %u, seq %u, ttl %2d, v %d, length %zd\n", 
     267                printf("%s: ICMP echo reply, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", 
    268268                        name, icmp_packet->uid, ntohs(icmp_packet->seqno), 
    269269                        icmp_packet->ttl, icmp_packet->version, 
     
    271271                break; 
    272272        case ECHO_REQUEST: 
    273                 printf("%s: ICMP echo request, id %u, seq %u, ttl %2d, v %d, length %zd\n", 
     273                printf("%s: ICMP echo request, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", 
    274274                        name, icmp_packet->uid, ntohs(icmp_packet->seqno), 
    275275                        icmp_packet->ttl, icmp_packet->version, 
     
    277277                break; 
    278278        case TTL_EXCEEDED: 
    279                 printf("%s: ICMP time exceeded in-transit, id %u, seq %u, ttl %2d, v %d, length %zd\n", 
     279                printf("%s: ICMP time exceeded in-transit, id %hhu, seq %hu, ttl %2d, v %d, length %zu\n", 
    280280                        name, icmp_packet->uid, ntohs(icmp_packet->seqno), 
    281281                        icmp_packet->ttl, icmp_packet->version, 
     
    283283                break; 
    284284        default: 
    285                 printf("%s: ICMP type %u, length %zd\n", 
     285                printf("%s: ICMP type %hhu, length %zu\n", 
    286286                        name, icmp_packet->msg_type, (size_t)buff_len - sizeof(struct ether_header)); 
    287287                break; 
     
    306306               get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt)); 
    307307 
    308         printf("%s: UCAST, ttl %u, ", 
     308        printf("%s: UCAST, ttl %hu, ", 
    309309               get_name_by_macaddr((struct ether_addr *)unicast_packet->dest, read_opt), 
    310310               unicast_packet->ttl); 
     
    322322                break; 
    323323        default: 
    324                 printf(" unknown payload ether type: %u\n", ntohs(ether_header->ether_type)); 
     324                printf(" unknown payload ether type: %hu\n", ntohs(ether_header->ether_type)); 
    325325                break; 
    326326        } 
     
    344344               get_name_by_macaddr((struct ether_addr *)ether_header->ether_shost, read_opt)); 
    345345 
    346         printf("BCAST, orig %s, seqno %u, ", 
     346        printf("BCAST, orig %s, seqno %hu, ", 
    347347               get_name_by_macaddr((struct ether_addr *)bcast_packet->orig, read_opt), 
    348348               ntohs(bcast_packet->seqno)); 
     
    360360                break; 
    361361        default: 
    362                 printf(" unknown payload ether type: %u\n", ntohs(ether_header->ether_type)); 
     362                printf(" unknown payload ether type: %hu\n", ntohs(ether_header->ether_type)); 
    363363                break; 
    364364        } 
     
    493493 
    494494                        if ((size_t)read_len < sizeof(struct ether_header)) { 
    495                                 printf("Warning - dropping received packet as it is smaller than expected (%zd): %zd\n", 
     495                                printf("Warning - dropping received packet as it is smaller than expected (%zu): %zd\n", 
    496496                                        sizeof(struct ether_header), read_len); 
    497497                                continue; 
     
    539539                                break; 
    540540                        default: 
    541                                 printf("Warning - packet contains unknown ether type: %u\n", ether_type); 
     541                                printf("Warning - packet contains unknown ether type: %hu\n", ether_type); 
    542542                                break; 
    543543                        } 
  • trunk/batctl/traceroute.c

    r1463 r1477  
    115115        icmp_packet_out.seqno = 0; 
    116116 
    117         printf("traceroute to %s (%s), %d hops max, %zd byte packets\n", 
     117        printf("traceroute to %s (%s), %d hops max, %zu byte packets\n", 
    118118                dst_string, mac_string, TTL_MAX, sizeof(icmp_packet_out)); 
    119119 
     
    140140                        if (res <= 0) { 
    141141                                if (i == 0) 
    142                                         printf("%2u: ", icmp_packet_out.ttl); 
     142                                        printf("%2hu: ", icmp_packet_out.ttl); 
    143143 
    144144                                printf(" * "); 
     
    155155 
    156156                        if ((size_t)read_len < sizeof(icmp_packet_in)) { 
    157                                 printf("Warning - dropping received packet as it is smaller than expected (%zd): %zd\n", 
     157                                printf("Warning - dropping received packet as it is smaller than expected (%zu): %zd\n", 
    158158                                        sizeof(icmp_packet_in), read_len); 
    159159                                continue; 
     
    177177 
    178178                                if (!bat_host) 
    179                                         printf("%2u: %s %.3f ms", 
     179                                        printf("%2hu: %s %.3f ms", 
    180180                                                icmp_packet_out.ttl, return_mac, time_delta); 
    181181                                else 
    182                                         printf("%2u: %s (%s) %.3f ms", 
     182                                        printf("%2hu: %s (%s) %.3f ms", 
    183183                                                icmp_packet_out.ttl, bat_host->name, return_mac, time_delta); 
    184184