bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

news about ifconfig


From: Marcus Brinkmann
Subject: news about ifconfig
Date: Fri, 12 Jan 2001 06:29:25 +0100
User-agent: Mutt/1.1.4i

Hi,

I am sometimes working on ifconfig. Currently, I have some basic support for
interface configuration (addr, brdaddr, dstaddr, netmask, etc), and a
flexible output format setup, which I want to show you now:

This is the standard format:

address@hidden:~/gnu/cvs/i/xx/ifconfig$ ./ifconfig -i lo -i dummy0
lo (1):
  inet address  127.0.0.1
  netmask       255.0.0.0
  flags         UP LOOPBACK RUNNING
  mtu           3904

dummy0 (2):
  inet address  127.0.0.2
  netmask       255.0.0.0
  flags         UP BROADCAST RUNNING NOARP
  mtu           1500

This is the netkit format:

address@hidden:~/gnu/cvs/i/xx/ifconfig$ ./ifconfig --format netkit -i lo -i 
dummy0
lo         Link encap:(not available)
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:3904  Metric:0

dummy0     Link encap:(not available)
          inet addr:127.0.0.2  Bcast:127.255.255.255  Mask:255.0.0.0
          UP BROADCAST RUNNING NOARP  MTU:1500  Metric:0


You can specify your own format strings. This is like if_nameindex:

echo ./ifconfig --format '${first?}{}{\n}${name}${\n}${index}' -i lo -i dummy0'
lo
1
dummy0
2

There are basic if constructs ${cond?}{true}{false}, and variable
substitution like ${name}. Currently, it's quite basic, but I plan to
improve it a bit more, together with the rest of the program. The code is
nto bad, but also not very clever currently. This will improve.

Hope you like it. With sufficient flexibility, this should make it more user
friendly, and also usable in scripts (where parsing the output of a program
can be problematic, if you don't have control). I will try to provide some
input flexibility, too. For GNU style I want to use options as with every
GNU program, but for compatibility, stuff like "dummy0 127.0.0.1 up" could
also be supported (to some extent).

To finish, here are the default format strings as seen above:

struct format
{
  char *name;
  char *templ;
} formats[] =
{
  { "gnu",
    "${first?}{}{${\n}}${name}${index?}{ (${index})}:${\n}" \
    "${addr?}{  inet address  ${addr}${\n}}" \
    "${netmask?}{  netmask       ${netmask}${\n}}" \
    "${flags?}{  flags         ${flags}${\n}}" \
    "${mtu?}{  mtu           ${mtu}${\n}}"
  },
  { "netkit",
    "${name}       Link encap:(not available)${\n}" \
    "     inet addr:${addr}" \
    "${brdaddr?}{  Bcast:${brdaddr}}" \
    "${netmask?}{  Mask:${netmask}}" \
    "${newline}" \
    "     ${flags}" \
    "${mtu?}{  MTU:${mtu}}" \
    "${metric?}{  Metric:${metric}}" \
    "${newline}" \
    "${newline}"
  },
  /* Of the last entry, name is always 0, but templ is the current
     user specified format string.  */
  { 0, 0 }
};


-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org address@hidden
Marcus Brinkmann              GNU    http://www.gnu.org    address@hidden
address@hidden
http://www.marcus-brinkmann.de



reply via email to

[Prev in Thread] Current Thread [Next in Thread]