LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-27-2004, 03:39 AM   #1
ofada
Member
 
Registered: Jan 2004
Posts: 32

Rep: Reputation: 15
dhcp linux c++


Hi
How to know if a computer is using dhcp (dynamic ip) on a local network in C++??
thanks
bye
 
Old 01-29-2004, 04:20 AM   #2
jinksys
Member
 
Registered: Aug 2003
Location: 63123
Distribution: OpenSuSE/Ubuntu
Posts: 419

Rep: Reputation: 35
ofada,
there are no standard C++ calls to find that out...but,

you can check the contents of /proc/sys/net/ipv4/ip_autoconfig,
if it is 0, then you are using a static IP
if it is 1, then you are using a dynamic IP (BOOT, RARP, DHCP)
I dont trust that file though, since I use DHCP and it is 0 on my machine.

you could reach into /etc/sysconfig/network/ifcfg-eth0 (or any other legal device name) and look for the BOOTPROTO variable, which should equal DHCP. But I am not sure if each distro implements sysconfig the same, if at all.

lastly, with root access, you could parse the output of 'ifstatus' for lease information.

. . .what exactly are you trying to do?
 
Old 01-29-2004, 01:49 PM   #3
ofada
Member
 
Registered: Jan 2004
Posts: 32

Original Poster
Rep: Reputation: 15
Thanks for your reply jinksys.

I have a project to do in C/C++ which consist to detect all the hardware of a computer, his MAC address, IP (local) and to know if it is using dhcp or not.For the hardware I am using the detect library but this library doesn't allow to know the ip and if the computer is using dhcp.The program have to work on all linux computer.
Bye
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Zoom modem/switch & linux<->linux network: DHCP / Static ? tredegar Linux - Networking 8 11-11-2007 03:41 AM
why DHCP client not sending own host name in DHCP request packet? sonika_singhi Linux - Networking 7 05-28-2005 05:18 AM
Linux DHCP abhijeetudas Linux - Networking 6 12-17-2004 05:12 PM
DHCP in linux e1000 Linux - Networking 3 11-29-2003 04:08 AM
XP Pro Build 2600/sp1 v.1105 DHCP Client to Redhat 8.0 DHCP Server - Problems atomant Linux - Networking 5 06-28-2003 11:24 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration