라벨이 network인 게시물 표시

OS/2 codes: How to get a network interface name from an index and a description of struct ifmib

OS/2 socket call, os2_ioctl( SIOSTATIF42 ), provides the informations about network interfaces available on a machine through struct ifmib . However, struct ifmib does not have a member for a canonical network interface name such as 'lan0'. Instead of, it has an index and a description of a network interface. Fortunately, with those informations it's possible to get a canonical network interface name. An algorithm for this can be found in ODIN sources. See http://trac.netlabs.org/odin32/browser/trunk/src/iphlpapi/iphlpapi.cpp#L169   Based on the above codes, I've made an utility function to get a canonical network name from an index and a description of struct ifmib . See source: https://github.com/komh/os2codes/blob/master/network/getifname.c header: https://github.com/komh/os2codes/blob/master/network/getifname.h test: https://github.com/komh/os2codes/blob/master/network/getifname-test.c

OS/2 codes: How to get MAC address of network interfaces

MAC address is an 48-bits unique hardware address of a network adapter. OS/2 provides socket calls to retrive MAC address from network adapters. First way is to use os2_ioctl( SIOSTATIF42 ) . It returns the informations about all network interfaces available on a machine into struct ifmib . struct ifmib is based on an index of a network interface. That is, it does not provides canonical name of a network interface such as lan0. You should mangle a canonical name from a description field and an index field. For details, see the following ODIN sources. http://trac.netlabs.org/odin32/browser/trunk/src/iphlpapi/iphlpapi.cpp#L169 Second is ioctl( SIOCGIFCONF ) . It returns the information about all network interfaces available on a machine into struct ifconf . On TCP/IP v4.21 or later, struct ifconf may contain AF_LINK address storage. In this case, strcut ifconf contains a canonical name of a network interface, its index and its MAC address. Here is the implementation to re...