I am doing a network connection test program but I have no idea how to do the DHCP.

For dns, gateway I am using ping command called by popen.
For DHCP , i was told to to a dhcp discovery. Basically the DHCP client is already running in DHCP server.

I read somewhere that ifdown, ifup command can be used to but have no idea how. Any idea ?

I am making the program in C ( Linux 2.6 ).