Changeset 2216d25


Ignore:
Timestamp:
03/11/13 11:12:36 (9 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
524ebb5
Parents:
6e6577d
Message:
  • Make tracetop display addresses properly on FreeBSD
File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracetop/tracetop.cc

    r05a3177 r2216d25  
    1717#include <netpacket/packet.h>
    1818#include <net/ethernet.h>
     19#else
     20#include <net/if_dl.h>
    1921#endif
    2022
     
    9092        size_t mybufflen = buffer ? bufflen : sizeof(intbuffer);
    9193        int err;
     94
     95        /* Some systems (FreeBSD and Solaris, I'm looking at you) have a bug
     96         * where they can't deal with the idea of a sockaddr_storage being
     97         * passed into getnameinfo. Linux just deals by looking
     98         * at sa_family and figuring out what sockaddr it is really.
     99         *
     100         * Anyway, the fix appears to be to manually hax the sockaddr length
     101         * to be the right value for the underlying family.
     102         */
    92103        switch (a->sa_family) {
    93104                case AF_INET:
    94                 case AF_INET6:
     105                        salen = sizeof(struct sockaddr_in);
    95106                        if ((err=getnameinfo(a, salen, mybuf, mybufflen, NULL, 0, NI_NUMERICHOST))!=0) {
    96107                                strncpy(mybuf,gai_strerror(err),mybufflen);
    97108                        }
    98109                        break;
     110                case AF_INET6:
     111                        salen = sizeof(struct sockaddr_in6);
     112                        if ((err=getnameinfo(a, salen, mybuf, mybufflen, NULL, 0, NI_NUMERICHOST))!=0) {
     113                                strncpy(mybuf,gai_strerror(err),mybufflen);
     114                        }
     115                        break;
    99116#ifdef HAVE_NETPACKET_PACKET_H
    100117                case AF_PACKET:
    101118                        trace_ether_ntoa(((struct sockaddr_ll*)a)->sll_addr, mybuf);
     119                        break;
     120#else
     121                case AF_LINK:
     122                        trace_ether_ntoa((uint8_t *)((struct sockaddr_dl *)a)->sdl_data, mybuf);
    102123                        break;
    103124#endif
Note: See TracChangeset for help on using the changeset viewer.