On Thu, Feb 19, 2009 at 11:43 AM, Hugo Vanwoerkom <hvw59601@care2.com> wrote:
Hi,
Ifconfig says:
...
ppp0 Link encap:Point-to-Point Protocol
inet addr:200.57.201.43 P-t-P:200.57.219.18 Mask:255.255.255.255
...
I want that inet addr (200.57.201.43) in a program and I prefer not to run
the ifconfig command from it and grep it.
Does anyone know where else in the system that information resides?
I installed the net-tools source and looking at ifconfig.c it's not
immediately obvious.
Why don't you want to grep the output of ifconfig?
Maybe this would suit you:
http://www.geekpage.jp/en/programming/linux-network/get-ipaddr.php
(Changing eth0 to ppp0 obviously)
NB. To get that example to work I had to change the includes as follows:
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <unistd.h>