The suggestion to "read the code" was wonderfully more productive than the
suggestion to "read the documentation" it seems.

The code ends up looking like:


    natstat_t ns;
    natstat_t *nsp = &ns;
    ipfobj_t ipfreq;
    int natfd;

    bzero(&ipfreq, sizeof(ipfreq));
    ipfreq.info_rev = IPFILTER_VERSION;
    ipfreq.ipfo_size = sizeof(ns);
    ipfreq.ipfo_type = IPFOBJ_NATSTAT;
    ipfreq.ipfo_ptr = (void *)nsp;

    bzero(nsp, sizeof(ns));

    natfd = open(IPNAT_NAME, O_RDONLY);
    if (ioctl(natfd, SIOCGNATL, &ipfreq) == -1) {
        perror("ioctl(SIOCGNATL)");
        write_log(log_file, "ioctl(SIOCGNATL) failed: %s", strerror(errno));
        close(natfd);
        exit(-1);
        }
    close(natfd);

    ...

Thanks!

Reply via email to