Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "1 ioctl Function ioctl function get_ifi_info function ARP cache operations: eg. Print H/W addresses."— Presentation transcript:

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

2 2 ioctl Function #include int ioctl (int fd, int request, … /* void *arg */ ); returns: 0 if OK, -1 on error type of *arg depends on request CategoryrequestDescription socketSIOCATMARKat out-of-band mark ? SIOCSPGRPset process ID or process group ID of socket SIOCGPGRPget process ID or process group ID of socket fileFIONBIOset/clear nonblocking flag FIOASYNCset/cleat asynchronous i/o flag FIONREADget # bytes in receive buffer FIOSETOWNset process ID or process group ID of socket FIOGETOWNget process ID or process group ID of socket ARPSIOCSARPcreate/modify ARP entry SIOCGARPget ARP entry SIOCDARPdelete ARP entry

3 3 ioctl Function (Cont.) CategoryrequestDescription interfaceSIOCGIFCONFget list of all interfaces SIOCSIFADDRset interface address SIOCGIFADDRget interface address SIOCSIFFLAGSset interface flags SIOCGIFFLAGSget interface flags SIOCSIFDSTADDRset point-to-point address SIOCGIFDSTADDRget point-to-point address SIOCGIFBRDADDRget broadcast address SIOCSIFBRDADDRget broadcast address SIOCGIFNETMASKget subnet mask SIOCSIFNETMASKset subnet mask SIOCGIFMETRICget interface metric SIOCSIFMETRICset interface metric SIOC…(many more; implementation dependent) routingSIOCADDRTadd route SIOCDELRTdelete router

4 4 get_ifi_info Function returns 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 5 ARP Cache Operations e.g. print hardware addresses of host Get list of addresses and loop through each Print IP address Issue ioctl and print hardware address #include 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 */


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

Similar presentations


Ads by Google