From 28f540f45bbacd939bfd07f213bcad2bf730b1bf Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 Feb 1995 01:27:10 +0000 Subject: initial import --- misc/ioctltst.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 misc/ioctltst.c (limited to 'misc/ioctltst.c') diff --git a/misc/ioctltst.c b/misc/ioctltst.c new file mode 100644 index 0000000000..3e8ea997eb --- /dev/null +++ b/misc/ioctltst.c @@ -0,0 +1,55 @@ +#include +#include +#include +#include +#include +#include +#include + +/* + * open a socket, get the process group information of the socket, and use the + * socket to get the network interface configuration list + */ +main() +{ + int sock; + int ioctl_result; + + /* get a socket */ + sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if (sock < 0) + { + perror("Cannot create socket"); + exit(1); + } + + /* use ioctl() to get the process group information */ + { + int get_process_group; + + ioctl_result = ioctl(sock, SIOCGPGRP, (char *) &get_process_group); + + if (ioctl_result < 0) + { + int my_errno = errno; + + fprintf(stderr, "errno %d ", my_errno); + perror("ioctl(get process group)"); + } + } + + /* use ioctl() to get the interface configuration list */ + { + static struct ifconf ifc; /* init to 0 */ + + ioctl_result = ioctl(sock, SIOCGIFCONF, (char *) &ifc); + + if (ioctl_result < 0) + { + int my_errno = errno; + + fprintf(stderr, "errno %d ", my_errno); + perror("ioctl(get interface configuration list)"); + } + } +} -- cgit v1.2.3