Yeah, i have gone through ifconfig source and your steps are similar to what there is in inetplumb() function that plumbs an interface. But then...are the dlpi functions public? i dont think so...i didnt find any header that declares these methods on my system.
On Thu, Oct 1, 2009 at 8:51 PM, James Carlson <[email protected]>wrote: > Sebastien Roy wrote: > > On Thu, 2009-10-01 at 19:45 +0530, Vivek S wrote: > >> I can spawn ifconfig, but then how do i recognize errors? > >> > > > > You can tell whether the operation failed or not based on ifconfig's > > exit status. The problem is that you won't have fine-grained error > > semantics programatically (it would be unwise to parse the error strings > > printed to ifconfig's stderr). > > There might not be much you can *do* about any failures other than > passing them along for a human to interpret, so that doesn't seem to me > like an insurmountable problem. > > The only "big" problem I can see in that area is that the process that > invokes ifconfig may need to know what locale to use, so that the right > language error strings are produced. If this is far removed from the > user interface, it might be "hard" to do it right, where numeric error > codes would be easier to transport around. > > If the original poster really wants to do this one by hand, then the > process (for Ethernet-like interfaces) looks something like this: > > - Open the DLPI device as "fd1". It might be named "/dev/name" or > "/dev/nameN", depending on DLPI "style." > > - ioctl(fd1, I_PUSH, "ip"); > > - ioctl(fd1, I_PUSH, "arp"); > > - ioctl(fd1, SIOCGLIFFLAGS, &lifr) to get flags. > > - ioctl(fd1, SIOCSLIFNAME, &lifr) to set lifr_ppa and lifr_flags. > > - Open "/dev/udp" as "fd2." This is the mux stream. > > - ioctl(fd2, I_PUSH, "arp"); > > - Open the DLPI device again as "fd3." This is the ARP stream. > > - ioctl(fd3, I_PUSH, "arp"); > > - ioctl(fd3, SIOCSLIFNAME, &lifr) to set interface name for arp. > > - ioctl(fd2, I_PLINK, fd1); > > - ioctl(fd2, I_PLINK, fd3); > > - close fd1, fd2, and fd3. You're done. > > The original poster should also be aware that, other than pushing the > "ip" module on top of a DLPI stream, everything about this sequence > reeks of internal implementation details, and could (and has) changed > over time. Also note that the above doesn't handle IPMP or IPv6, and > probably has other functional defects as well. It's the bare minimum; > you get much more by using ifconfig. > > -- > James Carlson 42.703N 71.076W <[email protected]> >
_______________________________________________ networking-discuss mailing list [email protected]
