Here's the source code for the CERT program ...
/*
Copyright (c) Carnegie Mellon University 1994
CERT Coordination Center
Software Engineering Institute
Carnegie Mellon University
Pittsburgh, PA 15213-3890
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/mbuf.h>
#include <sys/map.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <net/if.h>
#define MAXINTERFACES 16
main (argc, argv)
register int argc;
register char *argv[];
{
register int fd, intrface, retn = 0;
struct ifreq buf[MAXINTERFACES];
struct ifconf ifc;
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) >= 0) {
ifc.ifc_len = sizeof buf;
ifc.ifc_buf = (caddr_t) buf;
if (!(ioctl (fd, SIOCGIFCONF, (char *) &ifc))) {
intrface = ifc.ifc_len / sizeof (struct ifreq);
while (intrface-- > 0)
if (!(ioctl (fd, SIOCGIFFLAGS, (char *) &buf[intrface]))) {
if (buf[intrface].ifr_flags & IFF_PROMISC) {
puts (buf[intrface].ifr_name);
retn++;
}
} else {
char str[256];
sprintf (str, "cpm: ioctl device %s", buf[intrface].ifr_name);
perror (str);
}
} else
perror ("cpm: ioctl");
} else
perror ("cpm: socket");
close (fd);
return retn;
}
---
Florian Schnabel
fs @
colin .
muc .
de
References:
|
|