Linux.com

VFaul

VFaul

  • Linux.com Member
  • Posts: 4
  • Member Since: 24 Nov 10
  • Last Logged In: 05 Apr 11

Latest Posts

Posted by
Topic
Post Preview
Posted
  • VFaul
    RE: Turn off promiscuous mode console messages
    I understand I can redirect to null in comand line or script. However, the message is being displayed during library call to pcap_open_live() in the libpcap library. Anyways, I have found the printk statement in the kernel file /net/core/dev.c., function dev_set_promiscuity(). So, I just commented it out and rebuilt the kernel for my embedded system.
    Link to this post 06 Apr 11

    I understand I can redirect to null in comand line or script. However, the message is being displayed during library call to pcap_open_live() in the libpcap library.
    Anyways, I have found the printk statement in the kernel file /net/core/dev.c., function dev_set_promiscuity(). So, I just commented it out and rebuilt the kernel for my embedded system.

  • VFaul
    Turn off promiscuous mode console messages
    I created a thread to continually sniff certain network packets at the datalink layer every few seconds using libpcap. eth0 is being opened in promiscuous mode. I do not want to leave the pcap object open, so I am calling pcap_open_live() and pcap_close() each time in the loop. This results in [quote]entered promiscuous mode[/quote] and [quote]left promiscuous mode[/quote] messages continually printed to the console. How do I turn off or delete these messages? I looked in the libpcap source code, but could not find these messages.
    Link to this post 05 Apr 11

    I created a thread to continually sniff certain network packets at the datalink layer every few seconds using libpcap. eth0 is being opened in promiscuous mode. I do not want to leave the pcap object open, so I am calling pcap_open_live() and pcap_close() each time in the loop. This results in

    entered promiscuous mode
    and
    left promiscuous mode
    messages continually printed to the console.
    How do I turn off or delete these messages? I looked in the libpcap source code, but could not find these messages.

  • VFaul
    RE: EMAC Link Status
    #include #include #include #include #include #include #include int main ( int argc, char **argv ) { struct ifreq ifr; int sock = socket ( AF_INET, SOCK_DGRAM, 0 ); struct ethtool_cmd edata; char ifname[32]; int result; strcpy ( ifname, "eth0" ); strncpy ( ifr.ifr_name, ifname, sizeof ( ifr.ifr_name )); ifr.ifr_addr.sa_family = AF_INET; result = ioctl ( sock, SIOCGIFFLAGS, &ifr ); if ( result == 0 ) { // successfully got the flags if ( ifr.ifr_flags | IFF_UP ) { printf ( "Ethernet interface is up\n" ); } else { printf ( "Ethernet interface is down\n" ); } } else { printf ( "%s: Error getting ethernet flags. %s (%d)\n", __FUNCTION__, strerror ( errno ), errno ); } ifr.ifr_data = (char *) &edata; edata.cmd = ETHTOOL_GSET; result = ioctl ( sock, SIOCETHTOOL, &ifr ); if ( result == 0 ) { switch ( edata.speed ) { case SPEED_10: printf ( "Speed is 10Mbps\n" ); break; case SPEED_100: printf ( "Speed is 100Mbps\n" ); break; case SPEED_1000: printf ( "Speed is 1Gbps\n" ); break; case SPEED_10000: printf ( "Speed is 10Gbps\n" ); break; default: printf ( "Speed (%d) is unknown\n", edata.speed ); break; } if ( edata.duplex == DUPLEX_HALF ){ printf ( "Half duplex\n" ); } else { printf ( "Full duplex\n" ); } } else { printf ( "%s: Error getting ethernet info. %s (%d)\n", __FUNCTION__, strerror ( errno ), errno ); } return 0; }
    Link to this post 30 Nov 10

    #include <errno.h>
    #include <linux/ethtool.h>
    #include <linux/sockios.h>
    #include <net/if.h>
    #include <stdio.h>
    #include <string.h>
    #include <sys/ioctl.h>

    int main ( int argc, char **argv )
    {
    struct ifreq ifr;
    int sock = socket ( AF_INET, SOCK_DGRAM, 0 );
    struct ethtool_cmd edata;
    char ifname[32];
    int result;

    strcpy ( ifname, "eth0" );
    strncpy ( ifr.ifr_name, ifname, sizeof ( ifr.ifr_name ));
    ifr.ifr_addr.sa_family = AF_INET;

    result = ioctl ( sock, SIOCGIFFLAGS, &ifr );
    if ( result == 0 ) {
    // successfully got the flags
    if ( ifr.ifr_flags | IFF_UP ) {
    printf ( "Ethernet interface is up\n" );
    }
    else {
    printf ( "Ethernet interface is down\n" );
    }
    }
    else {
    printf ( "%s: Error getting ethernet flags. %s (%d)\n",
    __FUNCTION__,
    strerror ( errno ),
    errno );
    }

    ifr.ifr_data = (char *) &edata;
    edata.cmd = ETHTOOL_GSET;
    result = ioctl ( sock, SIOCETHTOOL, &ifr );
    if ( result == 0 ) {
    switch ( edata.speed ) {
    case SPEED_10:
    printf ( "Speed is 10Mbps\n" );
    break;
    case SPEED_100:
    printf ( "Speed is 100Mbps\n" );
    break;
    case SPEED_1000:
    printf ( "Speed is 1Gbps\n" );
    break;
    case SPEED_10000:
    printf ( "Speed is 10Gbps\n" );
    break;
    default:
    printf ( "Speed (%d) is unknown\n", edata.speed );
    break;
    }

    if ( edata.duplex == DUPLEX_HALF ){
    printf ( "Half duplex\n" );
    }
    else {
    printf ( "Full duplex\n" );
    }
    }
    else {
    printf ( "%s: Error getting ethernet info. %s (%d)\n",
    __FUNCTION__,
    strerror ( errno ),
    errno );
    }
    return 0;
    }

  • VFaul
    EMAC Link Status
    In C code, I'm trying to retrieve the emac link status, speed, and duplex. I made a system call to "cat /proc/net/emac_link" and parsed the output. But this takes WAY too much time (around 75ms). Is there a faster (and better) way to get this information, say, through a driver IOCTL?
    Link to this post 25 Nov 10

    In C code, I'm trying to retrieve the emac link status, speed, and duplex. I made a system call to "cat /proc/net/emac_link" and parsed the output. But this takes WAY too much time (around 75ms). Is there a faster (and better) way to get this information, say, through a driver IOCTL?

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board