[ale] C question
Gary Maltzen
maltzen at mm.com
Tue Sep 19 17:44:14 EDT 2000
An IPv4 address (or mask) is a 32-bit number; for convenience it is
represented as four bytes using dotted decimal notation.
10.20.30.40 means (C-expression-wise)
(10 << 24) | (20 << 16) | (30 << 8) | 40
See 'man ntohs' for byte-order conversions.
The "system" function requires a command string, i.e.
"/sbin/ifconfig eth0 10.20.30.40"
This means you will have to convert each of the four component bytes to a
decimal equivalent for inclusion in the string you pass to the "system"
function.
>
> I have a question for the C guru's. This si my story. I can't use
> perl. and I don't really have access to a shell, I need to write a C
> program that can collect a little data and run the ifconfig
> command. Pretty simple really thanks to C's built in
> system() function. However this is my problem. I need to collect the IP
> address, and the netmask. It's not really a number? Is it a character
> array? Will that work when I pass a character array to the system
> function?
>
> Any thoughts our suggestions would be great.
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.
More information about the Ale
mailing list