Re: traffic counter in C




Hi again.

I'm trying to do something with netstat but it's giving segmentation
fault (core dumped):


#include <stdio.h>
#include <unistd.h>

void recv()
{
#define LINE_LENGTH 500
char output_recv[LINE_LENGTH];
FILE *grab_recv;

/* exec netstat -s */

execl("/usr/bin/netstat -s -p tcp", "", grab_recv);

/* grab the result */

fgets(output_recv, LINE_LENGTH, grab_recv);
pclose(grab_recv);

/* print the result */

sprintf (output_recv, "Recebidos %s bytes ", output_recv);
puts(output_recv);
}

main ()
{
/* exec recv() to know received traffic */

recv();

}

/* EOF */


guilherme.oliveira@xxxxxxxxx escreveu:
Hi !

I want to do a traffic counter in C for FreeBSD.
I have already done the daemon with forks but don't know where to get
the value of transfered data becayse these value isn't in '/proc'
(empty) or 'sysctl -a'

Any ideas ?

.



Relevant Pages

  • Re: traffic counter in C
    ... fault (core dumped): ... void recv() ... Unless execl() failed. ...
    (comp.unix.programmer)
  • Re: Core Drilling the San Andreas Fault
    ... Earthquake scientists from Stanford University and the United States ... Geological Survey said that the minerals taken from the core of the active ... fault could help scientists learn what triggers an earthquake and whether ... "Now we can hold the San Andreas fault in our hands," said Mark Zoback, a ...
    (sci.geo.geology)
  • Re: [PATCH -rt] update kmap_atomic on !HIGHMEM
    ... This patch adds the same as i386 HIGHMEM for!HIGHMEM. ... clean up the page fault disabling logic ... -static inline void pagefault_disable ...
    (Linux-Kernel)
  • Re: Creating and Maintaing Heavy and Light Versions of Classes
    ... In my mind the portable core code can ... > First we have the core classes (I'm omitting LightSubWidget) ... > class SubWidget: public LightSubWidget ... > void doSomethingTricky(); ...
    (comp.lang.cpp)
  • Re: Bahai Clearances
    ... > So your saying it is all the fault of the Universal House of Justice ... > That is the core issue, ... In these circumstances the UHJ is ... as the cost of his funeral. ...
    (talk.religion.bahai)