1 / 5

ioctl Function

ioctl Function. ioctl function get_ifi_info function ARP cache operations: eg. Print H/W addresses. ioctl Function. #include <unistd.h> int ioctl (int fd, int request, … /* void *arg */ ); returns: 0 if OK, -1 on error type of *arg depends on request.

penda
Download Presentation

ioctl Function

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ioctl Function • ioctl function • get_ifi_info function • ARP cache operations: eg. Print H/W addresses

  2. ioctl Function #include <unistd.h> int ioctl (int fd, int request, … /* void *arg */ ); returns: 0 if OK, -1 on error type of *arg depends on request

  3. ioctl Function (Cont.)

  4. get_ifi_info Functionreturns a linked list of ifconf structures • Create a TCP or UDP socket • Issue SIOCGIFCONF request in ioctl in a loop • Initialize linked list pointers • Step to next socket address structure • Handle aliases • Fetch interface flags • Allocate and initialize ifi_info structure

  5. ARP Cache Operationse.g. print hardware addresses of host • Get list of addresses and loop through each • Print IP address • Issue ioctl and print hardware address #include <net/if_arp.h> struct arpreq { struct sockaddr arp_pa; /* protocol address */ struct sockaddr arp_ha; /* hardware address */ int arp_flags; /* flags */ }; #define ATF_INUSE 0x01 /* entry in use */ #define ATF_COM 0x02 /* completed entry (hardware addr valid */ #define ATF_PERM 0x04 /* permanent entry */ #define ATF_PUBL 0x08 /* published entry (respond for other host */

More Related