| 1 | /* ioctl( SIOCGIFCONF ) test with TCPV40HDRS */
|
|---|
| 2 |
|
|---|
| 3 | #define TCPV40HDRS
|
|---|
| 4 |
|
|---|
| 5 | #include <stdio.h>
|
|---|
| 6 | #include <string.h>
|
|---|
| 7 |
|
|---|
| 8 | #include <types.h>
|
|---|
| 9 | #include <sys/socket.h> /* socket() */
|
|---|
| 10 | #include <unistd.h> /* soclose() */
|
|---|
| 11 | #include <sys/ioctl.h> /* ioctl(), SIOCGIFCONF */
|
|---|
| 12 | #include <net/if.h> /* struct ifreq */
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | #define MAX_NICS IFMIB_ENTRIES
|
|---|
| 16 |
|
|---|
| 17 | int main( void )
|
|---|
| 18 | {
|
|---|
| 19 | struct ifconf ifconf;
|
|---|
| 20 | struct ifreq if_list[ MAX_NICS ];
|
|---|
| 21 | int s;
|
|---|
| 22 | int rc;
|
|---|
| 23 |
|
|---|
| 24 | printf("Testing ioctl( SIOCGIFCONF ) with TCPV40HDRS...\n");
|
|---|
| 25 |
|
|---|
| 26 | s = socket( PF_INET, SOCK_RAW, 0 );
|
|---|
| 27 |
|
|---|
| 28 | memset( if_list, 0, sizeof( if_list ));
|
|---|
| 29 |
|
|---|
| 30 | ifconf.ifc_len = sizeof( if_list );
|
|---|
| 31 | ifconf.ifc_req = if_list;
|
|---|
| 32 | rc = ioctl( s, SIOCGIFCONF, &ifconf );
|
|---|
| 33 |
|
|---|
| 34 | soclose( s );
|
|---|
| 35 |
|
|---|
| 36 | printf("%s: rc = %d(0)\n", rc == 0 ? "PASSED" : "FAILED", rc );
|
|---|
| 37 |
|
|---|
| 38 | return rc == -1;
|
|---|
| 39 | }
|
|---|