lib/netdev-bsd.c
/* Retrieves current device stats for 'netdev'. */
Retrieves current device stats for 'netdev'.
Retrieves current device stats for ' netdev ' .
static int
netdev_bsd_get_stats(const struct netdev *netdev_, struct netdev_stats *stats)
{
#if defined(__FreeBSD__)
    int if_count, i;
    int mib[6];
    size_t len;
    struct ifmibdata ifmd;
    mib[0] = CTL_NET;
    mib[1] = PF_LINK;
    mib[2] = NETLINK_GENERIC;
    mib[3] = IFMIB_SYSTEM;
    mib[4] = IFMIB_IFCOUNT;
    len = sizeof(if_count);
    if (sysctl(mib, 5, &if_count, &len, (void *)0, 0) == -1) {
        VLOG_DBG_RL(&rl, "%s: sysctl failed: %s",
                    netdev_get_name(netdev_), ovs_strerror(errno));
        return errno;
    }
    mib[5] = IFDATA_GENERAL;
    mib[3] = IFMIB_IFDATA;
    len = sizeof(ifmd);
    for (i = 1; i <= if_count; i++) {
        mib[4] = i; 
        if (sysctl(mib, 6, &ifmd, &len, (void *)0, 0) == -1) {
            VLOG_DBG_RL(&rl, "%s: sysctl failed: %s",
                        netdev_get_name(netdev_), ovs_strerror(errno));
            return errno;
        } else if (!strcmp(ifmd.ifmd_name, netdev_get_name(netdev_))) {
            convert_stats(netdev_, stats, &ifmd.ifmd_data);
            break;
        }
    }
    return 0;
#elif defined(__NetBSD__)
    struct ifdatareq ifdr;
    int error;
    memset(&ifdr, 0, sizeof(ifdr));
    ovs_strlcpy(ifdr.ifdr_name, netdev_get_kernel_name(netdev_),
                sizeof(ifdr.ifdr_name));
    error = af_link_ioctl(SIOCGIFDATA, &ifdr);
    if (!error) {
        convert_stats(netdev_, stats, &ifdr.ifdr_data);
    }
    return error;
#else
#error not implemented
#endif
}
static int netdev_bsd_get_stats ( const struct netdev * netdev_ , struct netdev_stats * stats ) { #if defined ( __FreeBSD__ ) int if_count , i ; int mib [ 6 ] ; size_t len ; struct ifmibdata ifmd ; mib [ 0 ] = CTL_NET ; mib [ 1 ] = PF_LINK ; mib [ 2 ] = NETLINK_GENERIC ; mib [ 3 ] = IFMIB_SYSTEM ; mib [ 4 ] = IFMIB_IFCOUNT ; len = sizeof ( if_count ) ; if ( sysctl ( mib , 5 , & if_count , & len , ( void * ) 0 , 0 ) == -1 ) { VLOG_DBG_RL ( & rl , " " , netdev_get_name ( netdev_ ) , ovs_strerror ( errno ) ) ; return errno ; } mib [ 5 ] = IFDATA_GENERAL ; mib [ 3 ] = IFMIB_IFDATA ; len = sizeof ( ifmd ) ; for ( i = 1 ; i <= if_count ; i ++ ) { mib [ 4 ] = i ; if ( sysctl ( mib , 6 , & ifmd , & len , ( void * ) 0 , 0 ) == -1 ) { VLOG_DBG_RL ( & rl , " " , netdev_get_name ( netdev_ ) , ovs_strerror ( errno ) ) ; return errno ; } else if ( ! strcmp ( ifmd . ifmd_name , netdev_get_name ( netdev_ ) ) ) { convert_stats ( netdev_ , stats , & ifmd . ifmd_data ) ; break ; } } return 0 ; #elif defined ( __NetBSD__ ) struct ifdatareq ifdr ; int error ; memset ( & ifdr , 0 , sizeof ( ifdr ) ) ; ovs_strlcpy ( ifdr . ifdr_name , netdev_get_kernel_name ( netdev_ ) , sizeof ( ifdr . ifdr_name ) ) ; error = af_link_ioctl ( SIOCGIFDATA , & ifdr ) ; if ( ! error ) { convert_stats ( netdev_ , stats , & ifdr . ifdr_data ) ; } return error ; #else #error  not implemented #endif }
Retrieves current device stats for 'netdev'.
Retrieves current device stats for ' netdev ' .
/* row */